spot
0.8.2
|
00001 // Copyright (C) 2008 Laboratoire de Recherche et Development de 00002 // l'Epita (LRDE). 00003 // Copyright (C) 2003, 2004, 2005, 2006 Laboratoire d'Informatique de 00004 // Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC), 00005 // Université Pierre et Marie Curie. 00006 // 00007 // This file is part of Spot, a model checking library. 00008 // 00009 // Spot is free software; you can redistribute it and/or modify it 00010 // under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation; either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // Spot is distributed in the hope that it will be useful, but WITHOUT 00015 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00016 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00017 // License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with Spot; see the file COPYING. If not, write to the Free 00021 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00022 // 02111-1307, USA. 00023 00024 #ifndef SPOT_TGBAALGOS_GTEC_GTEC_HH 00025 # define SPOT_TGBAALGOS_GTEC_GTEC_HH 00026 00027 #include <stack> 00028 #include "status.hh" 00029 #include "tgbaalgos/emptiness.hh" 00030 #include "tgbaalgos/emptiness_stats.hh" 00031 00032 namespace spot 00033 { 00036 00140 emptiness_check* 00141 couvreur99(const tgba* a, 00142 option_map options = option_map(), 00143 const numbered_state_heap_factory* nshf 00144 = numbered_state_heap_hash_map_factory::instance()); 00145 00146 00150 class couvreur99_check: public emptiness_check, public ec_statistics 00151 { 00152 public: 00153 couvreur99_check(const tgba* a, 00154 option_map o = option_map(), 00155 const numbered_state_heap_factory* nshf 00156 = numbered_state_heap_hash_map_factory::instance()); 00157 virtual ~couvreur99_check(); 00158 00160 virtual emptiness_check_result* check(); 00161 00162 virtual std::ostream& print_stats(std::ostream& os) const; 00163 00172 const couvreur99_check_status* result() const; 00173 00174 protected: 00175 couvreur99_check_status* ecs_; 00181 void remove_component(const state* start_delete); 00182 00184 bool poprem_; 00186 unsigned removed_components; 00187 unsigned get_removed_components() const; 00188 unsigned get_vmsize() const; 00189 }; 00190 00195 class couvreur99_check_shy : public couvreur99_check 00196 { 00197 public: 00198 couvreur99_check_shy(const tgba* a, 00199 option_map o = option_map(), 00200 const numbered_state_heap_factory* nshf 00201 = numbered_state_heap_hash_map_factory::instance()); 00202 virtual ~couvreur99_check_shy(); 00203 00204 virtual emptiness_check_result* check(); 00205 00206 protected: 00207 struct successor { 00208 bdd acc; 00209 const spot::state* s; 00210 successor(bdd acc, const spot::state* s): acc(acc), s(s) {} 00211 }; 00212 00213 // We use five main data in this algorithm: 00214 // * couvreur99_check::root, a stack of strongly connected components (SCC), 00215 // * couvreur99_check::h, a hash of all visited nodes, with their order, 00216 // (it is called "Hash" in Couvreur's paper) 00217 // * arc, a stack of acceptance conditions between each of these SCC, 00218 std::stack<bdd> arc; 00219 // * num, the number of visited nodes. Used to set the order of each 00220 // visited node, 00221 int num; 00222 // * todo, the depth-first search stack. This holds pairs of the 00223 // form (STATE, SUCCESSORS) where SUCCESSORS is a list of 00224 // (ACCEPTANCE_CONDITIONS, STATE) pairs. 00225 typedef std::list<successor> succ_queue; 00226 00227 // Position in the loop seeking known successors. 00228 succ_queue::iterator pos; 00229 00230 struct todo_item 00231 { 00232 const state* s; 00233 int n; 00234 succ_queue q; // Unprocessed successors of S 00235 todo_item(const state* s, int n, couvreur99_check_shy* shy); 00236 }; 00237 00238 typedef std::list<todo_item> todo_list; 00239 todo_list todo; 00240 00241 void clear_todo(); 00242 00244 void dump_queue(std::ostream& os = std::cerr); 00245 00247 bool group_; 00248 // If the "group2" option is set (it implies "group"), we 00249 // reprocess the successor states of SCC that have been merged. 00250 bool group2_; 00251 // If the onepass option is true, do only one pass. This cancels 00252 // all the "shyness" of the algorithm, but we need the framework 00253 // of the implementation when working with GreatSPN. 00254 bool onepass_; 00255 00264 virtual numbered_state_heap::state_index_p find_state(const state* s); 00265 }; 00266 00267 00269 } 00270 00271 #endif // SPOT_TGBAALGOS_GTEC_GTEC_HH