spot  1.99.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
scc.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
3 // Laboratoire de 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 #pragma once
21 
22 #include <map>
23 #include <stack>
24 #include <vector>
25 #include "twa/twa.hh"
26 #include <iosfwd>
27 #include "misc/hash.hh"
28 #include "misc/bddlt.hh"
29 
30 namespace spot
31 {
32 
34  class SPOT_API scc_map
35  {
36  public:
37  typedef std::map<unsigned, bdd> succ_type;
38  typedef std::set<bdd, bdd_less_than> cond_set;
39 
44  scc_map(const const_twa_ptr& aut);
45 
46  ~scc_map();
47 
49  void build_map();
50 
52  const_twa_ptr get_aut() const;
53 
59  unsigned scc_count() const;
60 
64  unsigned initial() const;
65 
69  const succ_type& succ(unsigned n) const;
70 
76  bool trivial(unsigned n) const;
77 
81  bool accepting(unsigned n) const;
82 
86  const cond_set& cond_set_of(unsigned n) const;
87 
98  bdd ap_set_of(unsigned n) const;
99 
106  bdd aprec_set_of(unsigned n) const;
107 
111  acc_cond::mark_t acc_set_of(unsigned n) const;
112 
117  const std::set<acc_cond::mark_t>& useful_acc_of(unsigned n) const;
118 
125  const std::list<const state*>& states_of(unsigned n) const;
126 
133  const state* one_state_of(unsigned n) const;
134 
138  unsigned scc_of_state(const state* s) const;
139 
141  unsigned self_loops() const;
142 
143  protected:
144  bdd update_supp_rec(unsigned state);
145  int relabel_component();
146 
147  struct scc
148  {
149  public:
150  scc(int index) : index(index), acc(0U),
151  supp(bddtrue), supp_rec(bddfalse),
152  trivial(true) {};
154  int index;
159  std::list<const state*> states;
161  cond_set conds;
163  bdd supp;
165  bdd supp_rec;
167  succ_type succ;
169  bool trivial;
171  std::set<acc_cond::mark_t> useful_acc;
172  };
173 
174  const_twa_ptr aut_; // Automata to decompose.
175  typedef std::list<scc> stack_type;
176  stack_type root_; // Stack of SCC roots.
177  std::stack<acc_cond::mark_t> arc_acc_; // A stack of acceptance conditions
178  // between each of these SCC.
179  std::stack<bdd> arc_cond_; // A stack of conditions
180  // between each of these SCC.
181  typedef std::unordered_map<const state*, int,
182  state_ptr_hash, state_ptr_equal> hash_type;
183  hash_type h_; // Map of visited states. Values >= 0
184  // designate maximal SCC. Values < 0
185  // number states that are part of
186  // incomplete SCCs being completed.
187  int num_; // Number of visited nodes, negated.
188  typedef std::pair<const spot::state*, twa_succ_iterator*> pair_state_iter;
189  std::stack<pair_state_iter> todo_; // DFS stack. Holds (STATE,
190  // ITERATOR) pairs where
191  // ITERATOR is an iterator over
192  // the successors of STATE.
193  // ITERATOR should always be
194  // freed when TODO is popped,
195  // but STATE should not because
196  // it is used as a key in H.
197 
198  typedef std::vector<scc> scc_map_type;
199  scc_map_type scc_map_; // Map of constructed maximal SCC.
200  // SCC number "n" in H_ corresponds to entry
201  // "n" in SCC_MAP_.
202  unsigned self_loops_; // Self loops count.
203  };
204 
205  SPOT_API std::ostream&
206  dump_scc_dot(const const_twa_ptr& a,
207  std::ostream& out, bool verbose = false);
208  SPOT_API std::ostream&
209  dump_scc_dot(const scc_map& m, std::ostream& out, bool verbose = false);
210 }
Definition: public.hh:31
An Equivalence Relation for state*.
Definition: twa.hh:138
succ_type succ
Successor SCC.
Definition: scc.hh:167
Abstract class for states.
Definition: twa.hh:40
cond_set conds
Set of conditions used in the SCC.
Definition: scc.hh:161
Definition: scc.hh:147
std::set< acc_cond::mark_t > useful_acc
Set of acceptance combinations used in the SCC.
Definition: scc.hh:171
Hash Function for state*.
Definition: twa.hh:162
bdd supp_rec
Conjunction of atomic propositions used in the SCC.
Definition: scc.hh:165
bool trivial
Trivial SCC have one state and no self-loops.
Definition: scc.hh:169
acc_cond::mark_t acc
Definition: scc.hh:157
std::list< const state * > states
States of the component.
Definition: scc.hh:159
bdd supp
Conjunction of atomic propositions used in the SCC.
Definition: scc.hh:163
Build a map of Strongly Connected components in in a TGBA.
Definition: scc.hh:34
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 Jul 17 2015 23:40:21 for spot by doxygen 1.8.8