spot  2.16
twagraph.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) by the Spot authors, see the AUTHORS file for details.
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #pragma once
20 
21 #include <spot/twa/fwd.hh>
22 #include <spot/graph/graph.hh>
23 #include <spot/graph/ngraph.hh>
24 #include <spot/twa/bdddict.hh>
25 #include <spot/twa/twa.hh>
26 #include <spot/tl/formula.hh>
27 #include <sstream>
28 
29 namespace spot
30 {
31 
38  struct SPOT_API twa_graph_state: public spot::state
39  {
40  public:
41  twa_graph_state() noexcept
42  {
43  }
44 
47  {
48  }
49 
52  {
53  return *this;
54  }
55 
56  virtual ~twa_graph_state() noexcept
57  {
58  }
59 
60  virtual int compare(const spot::state* other) const override
61  {
62  auto o = down_cast<const twa_graph_state*>(other);
63 
64  // Do not simply return "other - this", it might not fit in an int.
65  if (o < this)
66  return -1;
67  if (o > this)
68  return 1;
69  return 0;
70  }
71 
72  virtual size_t hash() const override
73  {
74  return reinterpret_cast<size_t>(this);
75  }
76 
77  virtual twa_graph_state*
78  clone() const override
79  {
80  return const_cast<twa_graph_state*>(this);
81  }
82 
83  virtual void destroy() const override
84  {
85  }
86  };
87 
95  struct SPOT_API twa_graph_edge_data
96  {
97  bdd cond;
99 
100  explicit twa_graph_edge_data() noexcept
101  : cond(bddfalse), acc({})
102  {
103  }
104 
107  bdd cond,
108  acc_cond::mark_t acc = {}) noexcept
109  : cond(cond), acc(acc)
110  {
111  }
112 
114  bool operator<(const twa_graph_edge_data& other) const
115  {
116  if (cond.id() < other.cond.id())
117  return true;
118  if (cond.id() > other.cond.id())
119  return false;
120  return acc < other.acc;
121  }
122 
124  bool operator==(const twa_graph_edge_data& other) const
125  {
126  return cond.id() == other.cond.id() &&
127  acc == other.acc;
128  }
129  };
130 
131 
132 
137  template<class Graph>
138  class SPOT_API twa_graph_succ_iterator final:
139  public twa_succ_iterator
140  {
141  private:
142  typedef typename Graph::edge edge;
143  typedef typename Graph::state_data_t state;
144  const Graph* g_;
145  edge t_;
146  edge p_;
147 
148  public:
150  twa_graph_succ_iterator(const Graph* g, edge t)
151  : g_(g), t_(t)
152  {
153  }
154 
156  void recycle(edge t)
157  {
158  t_ = t;
159  }
160 
161  virtual bool first() override
162  {
163  p_ = t_;
164  return p_;
165  }
166 
167  virtual bool next() override
168  {
169  p_ = g_->edge_storage(p_).next_succ;
170  return p_;
171  }
172 
173  virtual bool done() const override
174  {
175  return !p_;
176  }
177 
178  virtual const twa_graph_state* dst() const override
179  {
180  SPOT_ASSERT(!done());
181  return &g_->state_data(g_->edge_storage(p_).dst);
182  }
183 
184  virtual bdd cond() const override
185  {
186  SPOT_ASSERT(!done());
187  return g_->edge_data(p_).cond;
188  }
189 
190  virtual acc_cond::mark_t acc() const override
191  {
192  SPOT_ASSERT(!done());
193  return g_->edge_data(p_).acc;
194  }
195 
197  edge pos() const
198  {
199  return p_;
200  }
201 
202  };
203 
206  class SPOT_API twa_graph final: public twa
207  {
208  public:
211  // We avoid using graph_t::edge_storage_t because graph_t is not
212  // instantiated in the SWIG bindings, and SWIG would therefore
213  // handle graph_t::edge_storage_t as an abstract type.
215  typedef spot::internal::edge_storage<unsigned, unsigned, unsigned,
216  internal::boxed_label
217  <twa_graph_edge_data, false>>
219  static_assert(std::is_same<typename graph_t::edge_storage_t,
220  edge_storage_t>::value, "type mismatch");
221  // We avoid using graph_t::state for the very same reason.
222  typedef unsigned state_num;
223  static_assert(std::is_same<typename graph_t::state, state_num>::value,
224  "type mismatch");
225 
226  protected:
228  mutable unsigned init_number_;
229 
230  public:
231 
233  twa_graph(const bdd_dict_ptr& dict)
234  : twa(dict),
235  init_number_(0)
236  {
237  }
238 
240  explicit twa_graph(const const_twa_graph_ptr& other, prop_set p)
241  : twa(other->get_dict()),
242  g_(other->g_), init_number_(other->init_number_)
243  {
244  copy_acceptance_of(other);
245  copy_ap_of(other);
246  prop_copy(other, p);
247  }
248 
249  virtual ~twa_graph()
250  {
251  }
252 
253 #ifndef SWIG
255  template <typename State_Name,
256  typename Name_Hash = std::hash<State_Name>,
257  typename Name_Equal = std::equal_to<State_Name>>
259 
261  template <typename State_Name,
262  typename Name_Hash = std::hash<State_Name>,
263  typename Name_Equal = std::equal_to<State_Name>>
266  {
268  }
269 
271  namer<formula>*
273  {
274  return create_namer<formula>();
275  }
276 
281  void
283 #endif
284 
287  {
288  return g_;
289  }
290 
292  const graph_t& get_graph() const
293  {
294  return g_;
295  }
296 
298  unsigned num_states() const
299  {
300  return g_.num_states();
301  }
302 
304  unsigned num_edges() const
305  {
306  return g_.num_edges();
307  }
308 
311  {
312  bool univ = is_univ_dest(s);
313  if (SPOT_UNLIKELY((!univ && s >= num_states())
314  // univ destinations have at least length 2.
315  || (univ && 2 + ~s >= g_.dests_vector().size())))
316  throw std::invalid_argument
317  ("set_init_state() called with nonexisting state");
318  init_number_ = s;
319  }
320 
322  template<class I>
323  void set_univ_init_state(I dst_begin, I dst_end)
324  {
325  auto ns = num_states();
326  for (I i = dst_begin; i != dst_end; ++i)
327  if (SPOT_UNLIKELY(*i >= ns))
328  throw std::invalid_argument
329  ("set_univ_init_state() called with nonexisting state");
330  init_number_ = g_.new_univ_dests(dst_begin, dst_end);
331  }
332 
334  void set_univ_init_state(const std::initializer_list<state_num>& il)
335  {
336  set_univ_init_state(il.begin(), il.end());
337  }
338 
341  {
342  // If the automaton has no state, it has no initial state.
343  if (num_states() == 0)
344  throw std::runtime_error("automaton has no state at all");
345  return init_number_;
346  }
347 
348  virtual const twa_graph_state* get_init_state() const override
349  {
350  unsigned n = get_init_state_number();
351  if (SPOT_UNLIKELY(!is_existential()))
352  throw std::runtime_error
353  ("the abstract interface does not support alternating automata");
354  return state_from_number(n);
355  }
356 
357  virtual twa_succ_iterator*
358  succ_iter(const state* st) const override
359  {
360  auto s = down_cast<const typename graph_t::state_storage_t*>(st);
361  SPOT_ASSERT(!s->succ || g_.is_valid_edge(s->succ));
362 
363  if (this->iter_cache_)
364  {
365  auto it =
366  down_cast<twa_graph_succ_iterator<graph_t>*>(this->iter_cache_);
367  it->recycle(s->succ);
368  this->iter_cache_ = nullptr;
369  return it;
370  }
371  return new twa_graph_succ_iterator<graph_t>(&g_, s->succ);
372  }
373 
375  static constexpr bool is_univ_dest(const edge_storage_t& e)
376  {
377  return is_univ_dest(e.dst);
378  }
379 
381  static constexpr bool is_univ_dest(unsigned s)
382  {
383  // Universal destinations are stored with their most-significant
384  // bit set.
385  return (int) s < 0;
386  }
387 
389  state_num
390  state_number(const state* st) const
391  {
392  auto s = down_cast<const typename graph_t::state_storage_t*>(st);
393  return s - &g_.state_storage(0);
394  }
395 
397  const twa_graph_state*
399  {
400  return &g_.state_data(n);
401  }
402 
404  std::string format_state(unsigned n) const;
405 
406  virtual std::string format_state(const state* st) const override
407  {
408  return format_state(state_number(st));
409  }
410 
412  unsigned edge_number(const twa_succ_iterator* it) const
413  {
414  auto* i = down_cast<const twa_graph_succ_iterator<graph_t>*>(it);
415  return i->pos();
416  }
417 
419  unsigned edge_number(const edge_storage_t& e) const
420  {
421  return g_.index_of_edge(e);
422  }
423 
426  {
427  return g_.edge_data(edge_number(it));
428  }
429 
432  {
433  return g_.edge_data(t);
434  }
435 
438  {
439  return g_.edge_data(edge_number(it));
440  }
441 
443  const twa_graph_edge_data& edge_data(unsigned t) const
444  {
445  return g_.edge_data(t);
446  }
447 
450  {
451  return g_.edge_storage(edge_number(it));
452  }
453 
456  {
457  return g_.edge_storage(t);
458  }
459 
461  const edge_storage_t
463  {
464  return g_.edge_storage(edge_number(it));
465  }
466 
468  const edge_storage_t edge_storage(unsigned t) const
469  {
470  return g_.edge_storage(t);
471  }
472 
474  unsigned new_state()
475  {
476  return g_.new_state();
477  }
478 
480  unsigned new_states(unsigned n)
481  {
482  return g_.new_states(n);
483  }
484 
489  unsigned new_edge(unsigned src, unsigned dst,
490  bdd cond,
491  acc_cond::mark_t acc = {})
492  {
493  return g_.new_edge(src, dst, cond, acc);
494  }
495 
499  unsigned new_acc_edge(unsigned src, unsigned dst,
500  bdd cond, bool acc = true)
501  {
502  if (acc)
503  return g_.new_edge(src, dst, cond, this->acc().all_sets());
504  else
505  return g_.new_edge(src, dst, cond);
506  }
507 
509  template<class I>
510  unsigned new_univ_edge(unsigned src, I begin, I end,
511  bdd cond,
512  acc_cond::mark_t acc = {})
513  {
514  return g_.new_univ_edge(src, begin, end, cond, acc);
515  }
516 
518  unsigned new_univ_edge(unsigned src, std::initializer_list<unsigned> dst,
519  bdd cond,
520  acc_cond::mark_t acc = {})
521  {
522  return g_.new_univ_edge(src, dst.begin(), dst.end(), cond, acc);
523  }
524 
525 #ifndef SWIG
527  internal::state_out<const graph_t>
528  out(unsigned src) const
529  {
530  return g_.out(src);
531  }
532 #endif
533 
535  internal::state_out<graph_t>
536  out(unsigned src)
537  {
538  return g_.out(src);
539  }
540 
542  internal::killer_edge_iterator<graph_t>
543  out_iteraser(unsigned src)
544  {
545  return g_.out_iteraser(src);
546  }
547 
549  internal::const_universal_dests
550  univ_dests(unsigned d) const noexcept
551  {
552  return g_.univ_dests(d);
553  }
554 
556  internal::const_universal_dests
557  univ_dests(const edge_storage_t& e) const noexcept
558  {
559  return g_.univ_dests(e);
560  }
561 
563  bool is_existential() const
564  {
565  return g_.is_existential();
566  }
567 
568 #ifndef SWIG
570  auto states() const
571  SPOT_RETURN(g_.states());
573  auto states()
574  SPOT_RETURN(g_.states());
575 
577  internal::all_trans<const graph_t>
578  edges() const noexcept
579  {
580  return g_.edges();
581  }
582 #endif
583 
585  internal::all_trans<graph_t>
586  edges() noexcept
587  {
588  return g_.edges();
589  }
590 
591 #ifndef SWIG
593  auto edge_vector() const
594  SPOT_RETURN(g_.edge_vector());
596  auto edge_vector()
597  SPOT_RETURN(g_.edge_vector());
598 #endif
599 
601  bool is_dead_edge(unsigned t) const
602  {
603  return g_.is_dead_edge(t);
604  }
605 
608  {
609  return g_.is_dead_edge(t);
610  }
611 
628  void merge_edges();
629 
634 
661 
672  unsigned merge_states_of(bool stable = true,
673  const std::vector<bool>* to_merge_ptr = nullptr);
674 
692 
710  typedef void (*shift_action)(const std::vector<unsigned>& newst,
711  void* action_data);
716  void purge_unreachable_states(shift_action* f = nullptr,
717  void* action_data = nullptr);
718 
724 
732 
736  {
737  if (SPOT_UNLIKELY(!(bool)prop_state_acc()))
738  throw std::runtime_error
739  ("state_acc_sets() should only be called on "
740  "automata with state-based acceptance");
741  for (auto& t: g_.out(s))
742  // Stop at the first edge, since the remaining should be
743  // labeled identically.
744  return t.acc;
745  return {};
746  }
747 
754  bool state_is_accepting(unsigned s) const
755  {
756  if (SPOT_UNLIKELY(!(bool)prop_state_acc()))
757  throw std::runtime_error
758  ("state_is_accepting() should only be called on "
759  "automata with state-based acceptance");
760  for (auto& t: g_.out(s))
761  // Stop at the first edge, since the remaining should be
762  // labeled identically.
763  return acc().accepting(t.acc);
764  return false;
765  }
766 
767  bool state_is_accepting(const state* s) const
768  {
769  return state_is_accepting(state_number(s));
770  }
772 
774  bool operator==(const twa_graph& aut) const
775  {
776  auto& dests1 = g_.dests_vector();
777  auto& dests2 = aut.get_graph().dests_vector();
778  if (num_states() != aut.num_states() ||
779  num_edges() != aut.num_edges() ||
780  num_sets() != aut.num_sets() ||
781  dests1.size() != dests2.size())
782  return false;
783  auto& trans1 = edge_vector();
784  auto& trans2 = aut.edge_vector();
785  if (!std::equal(trans1.begin() + 1, trans1.end(),
786  trans2.begin() + 1))
787  return false;
788  return std::equal(dests1.begin(), dests1.end(),
789  dests2.begin());
790  }
791 
792 #ifndef SWIG
815  void defrag_states(std::vector<unsigned>& newst,
816  unsigned used_states);
817 
818  // prototype was changed in Spot 2.10
819  SPOT_DEPRECATED("use reference version of this method")
820  void defrag_states(std::vector<unsigned>&& newst,
821  unsigned used_states)
822  {
823  return defrag_states(newst, used_states);
824  }
825 
832  void rename_states_(const std::vector<unsigned>& newst);
834 #endif // SWIG
835 
843  void kill_state(unsigned state);
844 
850  void dump_storage_as_dot(std::ostream& out,
851  const char* opt = nullptr) const;
852  };
853 
854  // This is a workaround for
855 #if __GNUC__ == 8 && __GNUC_MINOR__ == 2
856 # define SPOT_make_twa_graph__(...) \
857  std::shared_ptr<twa_graph>(new twa_graph(__VA_ARGS__))
858 #else
859 # define SPOT_make_twa_graph__(...) \
860  std::make_shared<twa_graph>(__VA_ARGS__)
861 #endif
862 
866  {
867  return SPOT_make_shared_enabled__(twa_graph, dict);
868  }
869 
873  twa::prop_set p)
874  {
875  return SPOT_make_shared_enabled__(twa_graph, aut, p);
876  }
877 
885  twa::prop_set p,
886  bool preserve_name_properties = false)
887  {
888  twa_graph_ptr res = SPOT_make_shared_enabled__(twa_graph, aut, p);
889  if (preserve_name_properties)
890  res->copy_named_properties_of(aut);
891  return res;
892  }
893 
903  SPOT_API twa_graph_ptr
905  bool preserve_names = false,
906  // parentheses for SWIG, see
907  // https://github.com/swig/swig/issues/993
908  unsigned max_states = -(1U));
909 }
unsigned num_states() const
The number of states in the automaton.
Definition: graph.hh:670
internal::killer_edge_iterator< digraph > out_iteraser(state_storage_t &src)
Return a fake container with all edges leaving src, allowing erasure.
Definition: graph.hh:945
state new_states(unsigned n, Args &&... args)
Create n new states.
Definition: graph.hh:709
state new_state(Args &&... args)
Create a new state.
Definition: graph.hh:695
edge index_of_edge(const edge_storage_t &tt) const
Convert a storage reference into an edge number.
Definition: graph.hh:907
bool is_valid_edge(edge t) const
Test whether the given edge is valid.
Definition: graph.hh:1011
edge_storage_t::data_t & edge_data(edge s)
Return the Edge_Data of an edge.
Definition: graph.hh:778
const dests_vector_t & dests_vector() const
The vector used to store universal destinations.
Definition: graph.hh:1039
edge_storage_t & edge_storage(edge s)
Return a reference to the storage of an edge.
Definition: graph.hh:760
bool is_existential() const
Whether the automaton uses only existential branching.
Definition: graph.hh:684
internal::state_out< digraph > out(state src)
Return a fake container with all edges leaving src.
Definition: graph.hh:916
state new_univ_dests(I dst_begin, I dst_end)
Create a new universal destination group.
Definition: graph.hh:821
internal::const_universal_dests univ_dests(state src) const
Return universal destinations for state src.
Definition: graph.hh:877
state_storage_t & state_storage(state s)
Return a reference to the storage of a state.
Definition: graph.hh:724
unsigned num_edges() const
The number of edges in the automaton.
Definition: graph.hh:678
state_storage_t::data_t & state_data(state s)
Return the State_Data associated to a state.
Definition: graph.hh:742
bool is_dead_edge(unsigned t) const
Test whether an edge has been erased.
Definition: graph.hh:1023
internal::edge_storage< state, state, edge, internal::boxed_label< twa_graph_edge_data > > edge_storage_t
Edge storage type.
Definition: graph.hh:632
edge new_univ_edge(state src, I dst_begin, I dst_end, Args &&... args)
Create a new universal edge.
Definition: graph.hh:856
edge new_edge(state src, state dst, Args &&... args)
Create a new edge.
Definition: graph.hh:797
internal::all_trans< const digraph > edges() const
Return a fake container with all edges (excluding erased edges)
Definition: graph.hh:975
A graph wrapper associating named states to graph state indices.
Definition: ngraph.hh:33
This class is used to tell parallel algorithms what resources they may use.
Definition: common.hh:157
Abstract class for states.
Definition: twa.hh:49
Iterator used by the on-the-fly interface of twa_graph.
Definition: twagraph.hh:140
virtual bool next() override
Jump to the next successor (if any).
Definition: twagraph.hh:167
twa_graph_succ_iterator(const Graph *g, edge t)
Construct an iterator starting at edge t of graph g.
Definition: twagraph.hh:150
virtual bdd cond() const override
Get the condition on the edge leading to this successor.
Definition: twagraph.hh:184
virtual acc_cond::mark_t acc() const override
Get the acceptance mark of the edge leading to this successor.
Definition: twagraph.hh:190
virtual bool first() override
Position the iterator on the first successor (if any).
Definition: twagraph.hh:161
edge pos() const
Returns the index of the current edge.
Definition: twagraph.hh:197
void recycle(edge t)
Reset the iterator to start from edge t.
Definition: twagraph.hh:156
virtual const twa_graph_state * dst() const override
Get the destination state of the current edge.
Definition: twagraph.hh:178
virtual bool done() const override
Check whether the iteration is finished.
Definition: twagraph.hh:173
Graph-based representation of a TωA.
Definition: twagraph.hh:207
namer< formula > * create_formula_namer()
Create a namer that associates formulas to states.
Definition: twagraph.hh:272
unsigned new_univ_edge(unsigned src, I begin, I end, bdd cond, acc_cond::mark_t acc={})
Create a universal edge from src to states in [begin, end).
Definition: twagraph.hh:510
void copy_state_names_from(const const_twa_graph_ptr &other)
Define the state names of this automaton using the names from other.
unsigned num_edges() const
Returns the number of edges in the automaton.
Definition: twagraph.hh:304
const twa_graph_state * state_from_number(state_num n) const
Returns the state pointer for state number n.
Definition: twagraph.hh:398
state_num state_number(const state *st) const
Returns the state number corresponding to state pointer st.
Definition: twagraph.hh:390
internal::state_out< graph_t > out(unsigned src)
Returns a range over outgoing edges of state src.
Definition: twagraph.hh:536
void merge_univ_dests()
Merge common universal destinations.
void release_formula_namer(namer< formula > *namer, bool keep_names)
Release a formula namer.
digraph< twa_graph_state, twa_graph_edge_data > graph_t
The underlying graph type.
Definition: twagraph.hh:210
virtual twa_succ_iterator * succ_iter(const state *st) const override
Get an iterator over the successors of local_state.
Definition: twagraph.hh:358
void merge_edges()
Merge edges that can be merged.
graph_t & get_graph()
Access the underlying digraph.
Definition: twagraph.hh:286
internal::state_out< const graph_t > out(unsigned src) const
Returns a range over outgoing edges of state src (const).
Definition: twagraph.hh:528
namer< State_Name, Name_Hash, Name_Equal > * create_namer()
Create a namer to associate custom names of type State_Name to states.
Definition: twagraph.hh:265
void kill_state(unsigned state)
Make a state dead.
unsigned merge_states_of(bool stable=true, const std::vector< bool > *to_merge_ptr=nullptr)
Like merge states, but one can chose which states are candidates for merging.
const twa_graph_edge_data & edge_data(const twa_succ_iterator *it) const
Returns the edge data at the position of iterator it (const).
Definition: twagraph.hh:437
unsigned edge_number(const twa_succ_iterator *it) const
Returns the index of the current edge of iterator it.
Definition: twagraph.hh:412
edge_storage_t & edge_storage(unsigned t)
Returns the edge storage for edge number t.
Definition: twagraph.hh:455
graph_t g_
The underlying graph.
Definition: twagraph.hh:224
bool state_is_accepting(unsigned s) const
Tell if a state is accepting.
Definition: twagraph.hh:754
unsigned new_acc_edge(unsigned src, unsigned dst, bdd cond, bool acc=true)
Create an edge from src to dst.
Definition: twagraph.hh:499
internal::killer_edge_iterator< graph_t > out_iteraser(unsigned src)
Returns an edge-erasing iterator over outgoing edges of src.
Definition: twagraph.hh:543
unsigned state_num
Numeric type used to identify states.
Definition: twagraph.hh:220
const twa_graph_edge_data & edge_data(unsigned t) const
Returns the edge data for edge number t (const overload).
Definition: twagraph.hh:443
unsigned init_number_
Number of the initial state.
Definition: twagraph.hh:228
edge_storage_t & edge_storage(const twa_succ_iterator *it)
Returns the edge storage at the position of iterator it.
Definition: twagraph.hh:449
void remove_unused_ap()
Remove unused atomic propositions.
void purge_dead_states()
Remove all dead states.
twa_graph_edge_data & edge_data(const twa_succ_iterator *it)
Returns the edge data at the current position of iterator it.
Definition: twagraph.hh:425
void purge_unreachable_states(shift_action *f=nullptr, void *action_data=nullptr)
Remove all unreachable states.
void defrag_states(std::vector< unsigned > &newst, unsigned used_states)
Renumber all states, and drop some.
twa_graph(const const_twa_graph_ptr &other, prop_set p)
Copy another automaton, keeping only the properties in p.
Definition: twagraph.hh:240
bool state_is_accepting(const state *s) const
Tell if a state is accepting.
Definition: twagraph.hh:767
const edge_storage_t edge_storage(unsigned t) const
Returns edge storage for edge number t (const overload).
Definition: twagraph.hh:468
state_num get_init_state_number() const
Returns the number of the initial state.
Definition: twagraph.hh:340
void set_univ_init_state(I dst_begin, I dst_end)
Set a universal initial state from a range of destination states.
Definition: twagraph.hh:323
static constexpr bool is_univ_dest(unsigned s)
Returns true iff destination s is a universal destination.
Definition: twagraph.hh:381
spot::internal::edge_storage< unsigned, unsigned, unsigned, internal::boxed_label< twa_graph_edge_data, false > > edge_storage_t
Edge storage type (src, dst, and edge data).
Definition: twagraph.hh:218
virtual const twa_graph_state * get_init_state() const override
Get the initial state of the automaton.
Definition: twagraph.hh:348
twa_graph_edge_data & edge_data(unsigned t)
Returns the edge data for edge number t.
Definition: twagraph.hh:431
unsigned num_states() const
Returns the number of states in the automaton.
Definition: twagraph.hh:298
auto states() const SPOT_RETURN(g_.states())
Returns a range over all states (const).
bool is_dead_edge(const graph_t::edge_storage_t &t) const
Returns true iff edge t is a dead (removed) edge.
Definition: twagraph.hh:607
void rename_states_(const std::vector< unsigned > &newst)
Rename all states.
void set_init_state(state_num s)
Set the initial state to state number s.
Definition: twagraph.hh:310
unsigned merge_states(parallel_policy ppolicy=parallel_policy())
Merge states that can be merged.
unsigned new_edge(unsigned src, unsigned dst, bdd cond, acc_cond::mark_t acc={})
Create a new edge from src to dst.
Definition: twagraph.hh:489
bool is_dead_edge(unsigned t) const
Returns true iff edge number t is a dead (removed) edge.
Definition: twagraph.hh:601
bool operator==(const twa_graph &aut) const
Structural equality: same states, edges, labels, and acceptance.
Definition: twagraph.hh:774
std::string format_state(unsigned n) const
Returns a human-readable representation of state number n.
internal::const_universal_dests univ_dests(unsigned d) const noexcept
Returns the universal destinations of dest-index d.
Definition: twagraph.hh:550
unsigned new_univ_edge(unsigned src, std::initializer_list< unsigned > dst, bdd cond, acc_cond::mark_t acc={})
Create a universal edge from src to the listed destinations.
Definition: twagraph.hh:518
virtual std::string format_state(const state *st) const override
Format the state as a string for printing.
Definition: twagraph.hh:406
const edge_storage_t edge_storage(const twa_succ_iterator *it) const
Returns edge storage at the position of iterator it (const).
Definition: twagraph.hh:462
void set_univ_init_state(const std::initializer_list< state_num > &il)
Set a universal initial state from an initializer list.
Definition: twagraph.hh:334
unsigned new_state()
Create a new state and return its number.
Definition: twagraph.hh:474
auto edge_vector() const SPOT_RETURN(g_.edge_vector())
Returns the raw edge storage vector (const).
static constexpr bool is_univ_dest(const edge_storage_t &e)
Returns true iff edge e has a universal destination.
Definition: twagraph.hh:375
acc_cond::mark_t state_acc_sets(unsigned s) const
Return the marks associated to a state if the acceptance is state-based.
Definition: twagraph.hh:735
const graph_t & get_graph() const
Access the underlying digraph (const overload).
Definition: twagraph.hh:292
bool is_existential() const
Whether the automaton uses only existential branching.
Definition: twagraph.hh:563
twa_graph(const bdd_dict_ptr &dict)
Construct an empty automaton using dict for BDD variables.
Definition: twagraph.hh:233
unsigned new_states(unsigned n)
Create n new states; return the number of the first one.
Definition: twagraph.hh:480
internal::const_universal_dests univ_dests(const edge_storage_t &e) const noexcept
Returns the universal destinations of edge e.
Definition: twagraph.hh:557
unsigned edge_number(const edge_storage_t &e) const
Returns the index of edge e.
Definition: twagraph.hh:419
internal::all_trans< graph_t > edges() noexcept
Returns a range over all edges.
Definition: twagraph.hh:586
void dump_storage_as_dot(std::ostream &out, const char *opt=nullptr) const
Print the data structures used to represent the automaton in dot's format.
Iterate over the successors of a state.
Definition: twa.hh:425
A Transition-based ω-Automaton.
Definition: twa.hh:648
unsigned num_sets() const
Number of acceptance sets used by the automaton.
Definition: twa.hh:949
LTL/PSL formula interface.
std::shared_ptr< bdd_dict > bdd_dict_ptr
Shared pointer to a bdd_dict.
Definition: bdddict.hh:304
std::shared_ptr< const twa > const_twa_ptr
Shared pointer to a const twa.
Definition: fwd.hh:36
std::shared_ptr< twa_graph > twa_graph_ptr
Shared pointer to a mutable twa_graph.
Definition: fwd.hh:44
std::shared_ptr< const twa_graph > const_twa_graph_ptr
Shared pointer to a const twa_graph.
Definition: fwd.hh:38
twa_graph_ptr make_twa_graph(const bdd_dict_ptr &dict)
Build an explicit automaton from all states of aut,.
Definition: twagraph.hh:865
Definition: automata.hh:26
An acceptance mark.
Definition: acc.hh:76
A structure for selecting a set of automaton properties to copy.
Definition: twa.hh:1548
Data attached to edges of a twa_graph.
Definition: twagraph.hh:96
acc_cond::mark_t acc
The acceptance mark of this edge.
Definition: twagraph.hh:98
bdd cond
The Boolean formula labeling this edge.
Definition: twagraph.hh:97
twa_graph_edge_data(bdd cond, acc_cond::mark_t acc={}) noexcept
Construct an edge labeled with cond and acceptance mark acc.
Definition: twagraph.hh:106
bool operator<(const twa_graph_edge_data &other) const
Lexicographic less-than comparison on (cond id, acc).
Definition: twagraph.hh:114
bool operator==(const twa_graph_edge_data &other) const
Equality: same condition and same acceptance mark.
Definition: twagraph.hh:124
Graph-based representation of a TωA.
Definition: twagraph.hh:39
virtual void destroy() const override
Release a state.
Definition: twagraph.hh:83
virtual int compare(const spot::state *other) const override
Compares two states (that come from the same automaton).
Definition: twagraph.hh:60
twa_graph_state & operator=(const twa_graph_state &) noexcept
Copy-assignment (no-op; graph states are identified by address).
Definition: twagraph.hh:51
virtual size_t hash() const override
Hash a state.
Definition: twagraph.hh:72
twa_graph_state(const twa_graph_state &) noexcept
Copy constructor (no-op; graph states are identified by address).
Definition: twagraph.hh:46
virtual twa_graph_state * clone() const override
Duplicate a state.
Definition: twagraph.hh:78

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.1