spot  1.2.1a
scc.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Laboratoire de
3 // Recherche et Développement de l'Epita.
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_TGBAALGOS_SCC_HH
21 # define SPOT_TGBAALGOS_SCC_HH
22 
23 #include <map>
24 #include <stack>
25 #include <vector>
26 #include "tgba/tgba.hh"
27 #include <iosfwd>
28 #include "misc/hash.hh"
29 #include "misc/bddlt.hh"
30 
31 namespace spot
32 {
33 
34  struct SPOT_API scc_stats
35  {
37  unsigned scc_total;
39  unsigned acc_scc;
44  unsigned dead_scc;
45 
51  unsigned acc_paths;
55  unsigned dead_paths;
56  unsigned self_loops;
57 
59  std::vector<bool> useless_scc_map;
60 
65 
66  std::ostream& dump(std::ostream& out) const;
67  };
68 
70  class SPOT_API scc_map
71  {
72  public:
73  typedef std::map<unsigned, bdd> succ_type;
74  typedef std::set<bdd, bdd_less_than> cond_set;
75 
80  scc_map(const tgba* aut);
81 
82  ~scc_map();
83 
85  void build_map();
86 
88  const tgba* get_aut() const;
89 
95  unsigned scc_count() const;
96 
100  unsigned initial() const;
101 
105  const succ_type& succ(unsigned n) const;
106 
112  bool trivial(unsigned n) const;
113 
117  bool accepting(unsigned n) const;
118 
122  const cond_set& cond_set_of(unsigned n) const;
123 
134  bdd ap_set_of(unsigned n) const;
135 
142  bdd aprec_set_of(unsigned n) const;
143 
147  bdd acc_set_of(unsigned n) const;
148 
153  bdd useful_acc_of(unsigned n) const;
154 
161  const std::list<const state*>& states_of(unsigned n) const;
162 
169  const state* one_state_of(unsigned n) const;
170 
174  unsigned scc_of_state(const state* s) const;
175 
177  unsigned self_loops() const;
178 
180  bool has_strong_scc() const;
181 
183  bool has_weak_scc() const;
184 
186  bool has_terminal_scc() const;
187 
188  bool weak_subautomaton(unsigned n) const;
189  bool terminal_subautomaton(unsigned n) const;
190  bool strong_hard(unsigned n) const;
191  bool weak_hard(unsigned n) const;
192  bool weak(unsigned n) const;
193  bool terminal(unsigned n) const;
194 
195  protected:
196  bdd update_supp_rec(unsigned state);
197  int relabel_component();
198  void update_strength();
199  bool intern_is_terminal(unsigned n);
200  bool intern_is_weak(unsigned n);
201  struct scc
202  {
203  public:
204  scc(int index) : index(index), acc(bddfalse),
205  supp(bddtrue), supp_rec(bddfalse),
206  trivial(true), useful_acc(bddfalse),
207  is_terminal(false), is_weak(false),
208  is_strong(false) {};
210  int index;
213  bdd acc;
215  std::list<const state*> states;
217  cond_set conds;
219  bdd supp;
221  bdd supp_rec;
223  succ_type succ;
225  bool trivial;
237  // \brief Wheter this scc is terminal
238  bool is_terminal;
239  // \brief Wheter this scc is weak
240  bool is_weak;
241  // \brief Wheter this scc is strong
242  bool is_strong;
243 
244  bool is_terminal_subautomaton;
245  bool is_weak_subautomaton;
246  bool is_weak_hard;
247  bool is_strong_subautomaton;
248  bool is_strong_hard;
249  };
250 
251  const tgba* aut_; // Automata to decompose.
252  typedef std::list<scc> stack_type;
253  stack_type root_; // Stack of SCC roots.
254  std::stack<bdd> arc_acc_; // A stack of acceptance conditions
255  // between each of these SCC.
256  std::stack<bdd> arc_cond_; // A stack of conditions
257  // between each of these SCC.
258  typedef Sgi::hash_map<const state*, int,
259  state_ptr_hash, state_ptr_equal> hash_type;
260  hash_type h_; // Map of visited states. Values >= 0
261  // designate maximal SCC. Values < 0
262  // number states that are part of
263  // incomplete SCCs being completed.
264  int num_; // Number of visited nodes, negated.
265  typedef std::pair<const spot::state*, tgba_succ_iterator*> pair_state_iter;
266  std::stack<pair_state_iter> todo_; // DFS stack. Holds (STATE,
267  // ITERATOR) pairs where
268  // ITERATOR is an iterator over
269  // the successors of STATE.
270  // ITERATOR should always be
271  // freed when TODO is popped,
272  // but STATE should not because
273  // it is used as a key in H.
274 
275  typedef std::vector<scc> scc_map_type;
276  scc_map_type scc_map_; // Map of constructed maximal SCC.
277  // SCC number "n" in H_ corresponds to entry
278  // "n" in SCC_MAP_.
279  unsigned self_loops_; // Self loops count.
280  };
281 
282  SPOT_API scc_stats
283  build_scc_stats(const tgba* a);
284  SPOT_API scc_stats
285  build_scc_stats(const scc_map& m);
286 
287  SPOT_API std::ostream&
288  dump_scc_dot(const tgba* a, std::ostream& out, bool verbose = false);
289  SPOT_API std::ostream&
290  dump_scc_dot(const scc_map& m, std::ostream& out, bool verbose = false);
291 }
292 
293 #endif // SPOT_TGBAALGOS_SCC_HH
this class acts like a wrapper to the C code of the open_set.
Definition: public.hh:32
bdd acc
Definition: scc.hh:213
An Equivalence Relation for state*.
Definition: state.hh:139
std::vector< bool > useless_scc_map
A map of the useless SCCs.
Definition: scc.hh:59
succ_type succ
Successor SCC.
Definition: scc.hh:223
Abstract class for states.
Definition: state.hh:40
unsigned acc_paths
Definition: scc.hh:51
bdd useful_acc
Set of acceptance combinations used in the SCC.
Definition: scc.hh:236
cond_set conds
Set of conditions used in the SCC.
Definition: scc.hh:217
Definition: scc.hh:201
bdd useful_acc
Definition: scc.hh:64
Hash Function for state*.
Definition: state.hh:164
A Transition-based Generalized Büchi Automaton.
Definition: tgba.hh:67
SPOT_API std::ostream & dump(std::ostream &os, const formula *f)
Dump a formula tree.
unsigned dead_paths
Definition: scc.hh:55
unsigned scc_total
Total number of SCCs.
Definition: scc.hh:37
bdd supp_rec
Conjunction of atomic propositions used in the SCC.
Definition: scc.hh:221
unsigned dead_scc
Definition: scc.hh:44
bool trivial
Trivial SCC have one state and no self-loops.
Definition: scc.hh:225
unsigned acc_scc
Total number of accepting SCC.
Definition: scc.hh:39
std::list< const state * > states
States of the component.
Definition: scc.hh:215
bdd supp
Conjunction of atomic propositions used in the SCC.
Definition: scc.hh:219
Build a map of Strongly Connected components in in a TGBA.
Definition: scc.hh:70
Definition: scc.hh:34

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Jun 5 2015 11:31:19 for spot by doxygen 1.8.9.1