spot
0.8.2
|
00001 // Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et 00002 // Développement de l'Epita (LRDE). 00003 // Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6), 00004 // département Systèmes Répartis Coopératifs (SRC), Université Pierre 00005 // 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 00025 #ifndef SPOT_TGBAALGOS_REDUCTGBA_SIM_HH 00026 #define SPOT_TGBAALGOS_REDUCTGBA_SIM_HH 00027 00028 #include "tgba/tgbareduc.hh" 00029 #include "tgbaalgos/reachiter.hh" 00030 #include <vector> 00031 #include <list> 00032 #include <sstream> 00033 00034 namespace spot 00035 { 00036 00039 00041 enum reduce_tgba_options 00042 { 00043 // Reduce_None and Reduce_All clash with the definitions in ltl::reduce 00044 // for Swig because Swig does not handle namespaces. 00045 #ifndef SWIG 00046 00047 Reduce_None = 0, 00048 #endif 00049 00050 Reduce_quotient_Dir_Sim = 1, 00052 Reduce_transition_Dir_Sim = 2, 00054 Reduce_quotient_Del_Sim = 4, 00056 Reduce_transition_Del_Sim = 8, 00058 Reduce_Scc = 16, 00059 #ifndef SWIG 00060 00061 Reduce_All = -1U 00062 #endif 00063 }; 00064 00072 const tgba* reduc_tgba_sim(const tgba* a, int opt = Reduce_All); 00073 00074 #ifndef SWIG 00075 00077 direct_simulation_relation* get_direct_relation_simulation(const tgba* a, 00078 std::ostream& os, 00079 int opt = -1); 00080 00083 delayed_simulation_relation* get_delayed_relation_simulation(const tgba* a, 00084 std::ostream& os, 00085 int opt = -1); 00086 00088 void free_relation_simulation(direct_simulation_relation* rel); 00090 void free_relation_simulation(delayed_simulation_relation* rel); 00091 00093 // simulation. 00094 00095 class spoiler_node; 00096 class duplicator_node; 00097 00098 typedef std::vector<spoiler_node*> sn_v; 00099 typedef std::vector<duplicator_node*> dn_v; 00100 typedef std::vector<const state*> s_v; 00101 00103 class parity_game_graph : public tgba_reachable_iterator_breadth_first 00104 { 00105 public: 00106 parity_game_graph(const tgba* a); 00107 virtual ~parity_game_graph(); 00108 00109 virtual simulation_relation* get_relation() = 0; 00110 00111 void print(std::ostream& os); 00112 00113 protected: 00114 sn_v spoiler_vertice_; 00115 dn_v duplicator_vertice_; 00116 s_v tgba_state_; 00117 int nb_node_parity_game; 00118 00119 void process_state(const state* s, int n, tgba_succ_iterator* si); 00120 00122 virtual void build_graph() = 0; 00123 00128 virtual void lift() = 0; 00129 }; 00130 00132 // Direct simulation. 00133 00135 class spoiler_node 00136 { 00137 public: 00138 spoiler_node(const state* d_node, 00139 const state* s_node, 00140 int num); 00141 virtual ~spoiler_node(); 00142 00146 bool add_succ(spoiler_node* n); 00147 void del_succ(spoiler_node* n); 00148 virtual void add_pred(spoiler_node* n); 00149 virtual void del_pred(); 00150 int get_nb_succ(); 00151 bool prune(); 00152 virtual bool set_win(); 00153 virtual std::string to_string(const tgba* a); 00154 virtual std::string succ_to_string(); 00155 virtual bool compare(spoiler_node* n); 00156 00157 const state* get_spoiler_node(); 00158 const state* get_duplicator_node(); 00159 state_couple* get_pair(); 00160 00161 bool not_win; 00162 int num_; // for the dot display. 00163 00164 protected: 00165 sn_v* lnode_succ; 00166 sn_v* lnode_pred; 00167 state_couple* sc_; 00168 }; 00169 00171 class duplicator_node : public spoiler_node 00172 { 00173 public: 00174 duplicator_node(const state* d_node, 00175 const state* s_node, 00176 bdd l, 00177 bdd a, 00178 int num); 00179 virtual ~duplicator_node(); 00180 00181 virtual bool set_win(); 00182 virtual std::string to_string(const tgba* a); 00183 virtual bool compare(spoiler_node* n); 00184 00185 bool match(bdd l, bdd a); 00186 bool implies(bdd l, bdd a); 00187 00188 bdd get_label() const; 00189 bdd get_acc() const; 00190 00191 protected: 00192 bdd label_; 00193 bdd acc_; 00194 }; 00195 00197 class parity_game_graph_direct : public parity_game_graph 00198 { 00199 public: 00200 parity_game_graph_direct(const tgba* a); 00201 ~parity_game_graph_direct(); 00202 00203 virtual direct_simulation_relation* get_relation(); 00204 00205 protected: 00206 virtual void build_graph(); 00207 virtual void lift(); 00208 void build_link(); 00209 00210 }; 00211 00212 00214 // Delayed simulation. 00215 00217 class spoiler_node_delayed : public spoiler_node 00218 { 00219 public: 00220 spoiler_node_delayed(const state* d_node, 00221 const state* s_node, 00222 bdd a, 00223 int num); 00224 ~spoiler_node_delayed(); 00225 00227 bool set_win(); 00228 bdd get_acceptance_condition_visited() const; 00229 virtual bool compare(spoiler_node* n); 00230 virtual std::string to_string(const tgba* a); 00231 int get_progress_measure() const; 00232 00233 bool get_lead_2_acc_all(); 00234 bool set_lead_2_acc_all(bdd acc = bddfalse); 00235 00236 // 00237 bool seen_; 00238 protected: 00241 bdd acceptance_condition_visited_; 00242 int progress_measure_; 00243 bool lead_2_acc_all_; 00244 }; 00245 00247 class duplicator_node_delayed : public duplicator_node 00248 { 00249 public: 00250 duplicator_node_delayed(const state* d_node, 00251 const state* s_node, 00252 bdd l, 00253 bdd a, 00254 int num); 00255 ~duplicator_node_delayed(); 00256 00258 bool set_win(); 00259 virtual std::string to_string(const tgba* a); 00260 bool implies_label(bdd l); 00261 bool implies_acc(bdd a); 00262 int get_progress_measure(); 00263 00264 bool get_lead_2_acc_all(); 00265 bool set_lead_2_acc_all(bdd acc = bddfalse); 00266 00267 // 00268 bool seen_; 00269 protected: 00270 int progress_measure_; 00271 bool lead_2_acc_all_; 00272 }; 00273 00274 00294 class parity_game_graph_delayed: public parity_game_graph 00295 { 00296 public: 00297 parity_game_graph_delayed(const tgba* a); 00298 ~parity_game_graph_delayed(); 00299 00300 virtual delayed_simulation_relation* get_relation(); 00301 00302 private: 00303 00306 typedef std::vector<bdd> bdd_v; 00307 bdd_v sub_set_acc_cond_; 00308 00310 int nb_set_acc_cond(); 00311 00313 duplicator_node_delayed* add_duplicator_node_delayed(const spot::state* sn, 00314 const spot::state* dn, 00315 bdd acc, 00316 bdd label, 00317 int nb); 00318 00320 spoiler_node_delayed* add_spoiler_node_delayed(const spot::state* sn, 00321 const spot::state* dn, 00322 bdd acc, 00323 int nb); 00324 00325 void build_recurse_successor_spoiler(spoiler_node* sn, 00326 std::ostringstream& os); 00327 void build_recurse_successor_duplicator(duplicator_node* dn, 00328 spoiler_node* sn, 00329 std::ostringstream& os); 00330 00332 virtual void build_graph(); 00333 00335 virtual void lift(); 00336 }; 00337 00338 #endif // SWIG 00339 00341 } 00342 00343 #endif // SPOT_TGBAALGOS_REDUCTGBA_SIM_HH