00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SPOT_TGBAALGOS_REDUCTGBA_SIM_HH
00024 #define SPOT_TGBAALGOS_REDUCTGBA_SIM_HH
00025
00026 #include "tgba/tgbareduc.hh"
00027 #include "tgbaalgos/reachiter.hh"
00028 #include <vector>
00029 #include <list>
00030 #include <sstream>
00031
00032 namespace spot
00033 {
00034
00037
00039 enum reduce_tgba_options
00040 {
00042 Reduce_None = 0,
00044 Reduce_quotient_Dir_Sim = 1,
00046 Reduce_transition_Dir_Sim = 2,
00048 Reduce_quotient_Del_Sim = 4,
00050 Reduce_transition_Del_Sim = 8,
00052 Reduce_Scc = 16,
00054 Reduce_All = -1U
00055 };
00056
00064 tgba* reduc_tgba_sim(const tgba* a, int opt = Reduce_All);
00065
00067 direct_simulation_relation* get_direct_relation_simulation(const tgba* a,
00068 std::ostream& os,
00069 int opt = -1);
00070
00073 delayed_simulation_relation* get_delayed_relation_simulation(const tgba* a,
00074 std::ostream& os,
00075 int opt = -1);
00076
00078 void free_relation_simulation(direct_simulation_relation* rel);
00080 void free_relation_simulation(delayed_simulation_relation* rel);
00081
00083
00084
00085 class spoiler_node;
00086 class duplicator_node;
00087
00088 typedef std::vector<spoiler_node*> sn_v;
00089 typedef std::vector<duplicator_node*> dn_v;
00090 typedef std::vector<const state*> s_v;
00091
00093 class parity_game_graph : public tgba_reachable_iterator_breadth_first
00094 {
00095 public:
00096 parity_game_graph(const tgba* a);
00097 virtual ~parity_game_graph();
00098
00099 virtual simulation_relation* get_relation() = 0;
00100
00101 void print(std::ostream& os);
00102
00103 protected:
00104 sn_v spoiler_vertice_;
00105 dn_v duplicator_vertice_;
00106 s_v tgba_state_;
00107 int nb_node_parity_game;
00108
00109 void start();
00110 void end();
00111 void process_state(const state* s, int n, tgba_succ_iterator* si);
00112 void process_link(int in, int out, const tgba_succ_iterator* si);
00113
00115 virtual void build_graph() = 0;
00116
00121 virtual void lift() = 0;
00122 };
00123
00125
00126
00128 class spoiler_node
00129 {
00130 public:
00131 spoiler_node(const state* d_node,
00132 const state* s_node,
00133 int num);
00134 virtual ~spoiler_node();
00135
00139 bool add_succ(spoiler_node* n);
00140 void del_succ(spoiler_node* n);
00141 virtual void add_pred(spoiler_node* n);
00142 virtual void del_pred();
00143 int get_nb_succ();
00144 bool prune();
00145 virtual bool set_win();
00146 virtual std::string to_string(const tgba* a);
00147 virtual std::string succ_to_string();
00148 virtual bool compare(spoiler_node* n);
00149
00150 const state* get_spoiler_node();
00151 const state* get_duplicator_node();
00152 state_couple* get_pair();
00153
00154 bool not_win;
00155 int num_;
00156
00157 protected:
00158 sn_v* lnode_succ;
00159 sn_v* lnode_pred;
00160 state_couple* sc_;
00161 };
00162
00164 class duplicator_node : public spoiler_node
00165 {
00166 public:
00167 duplicator_node(const state* d_node,
00168 const state* s_node,
00169 bdd l,
00170 bdd a,
00171 int num);
00172 virtual ~duplicator_node();
00173
00174 virtual bool set_win();
00175 virtual std::string to_string(const tgba* a);
00176 virtual bool compare(spoiler_node* n);
00177
00178 bool match(bdd l, bdd a);
00179 bool implies(bdd l, bdd a);
00180
00181 bdd get_label() const;
00182 bdd get_acc() const;
00183
00184 protected:
00185 bdd label_;
00186 bdd acc_;
00187 };
00188
00190 class parity_game_graph_direct : public parity_game_graph
00191 {
00192 public:
00193 parity_game_graph_direct(const tgba* a);
00194 ~parity_game_graph_direct();
00195
00196 virtual direct_simulation_relation* get_relation();
00197
00198 protected:
00199 virtual void build_graph();
00200 virtual void lift();
00201 void build_link();
00202
00203 };
00204
00205
00207
00208
00210 class spoiler_node_delayed : public spoiler_node
00211 {
00212 public:
00213 spoiler_node_delayed(const state* d_node,
00214 const state* s_node,
00215 bdd a,
00216 int num);
00217 ~spoiler_node_delayed();
00218
00220 bool set_win();
00221 bdd get_acceptance_condition_visited() const;
00222 virtual bool compare(spoiler_node* n);
00223 virtual std::string to_string(const tgba* a);
00224 int get_progress_measure() const;
00225
00226 bool get_lead_2_acc_all();
00227 bool set_lead_2_acc_all(bdd acc = bddfalse);
00228
00229
00230 bool seen_;
00231 protected:
00234 bdd acceptance_condition_visited_;
00235 int progress_measure_;
00236 bool lead_2_acc_all_;
00237 };
00238
00240 class duplicator_node_delayed : public duplicator_node
00241 {
00242 public:
00243 duplicator_node_delayed(const state* d_node,
00244 const state* s_node,
00245 bdd l,
00246 bdd a,
00247 int num);
00248 ~duplicator_node_delayed();
00249
00251 bool set_win();
00252 virtual std::string to_string(const tgba* a);
00253 bool implies_label(bdd l);
00254 bool implies_acc(bdd a);
00255 int get_progress_measure();
00256
00257 bool get_lead_2_acc_all();
00258 bool set_lead_2_acc_all(bdd acc = bddfalse);
00259
00260
00261 bool seen_;
00262 protected:
00263 int progress_measure_;
00264 bool lead_2_acc_all_;
00265 };
00266
00267
00287 class parity_game_graph_delayed: public parity_game_graph
00288 {
00289 public:
00290 parity_game_graph_delayed(const tgba* a);
00291 ~parity_game_graph_delayed();
00292
00293 virtual delayed_simulation_relation* get_relation();
00294
00295 private:
00296
00299 typedef std::vector<bdd> bdd_v;
00300 bdd_v sub_set_acc_cond_;
00301
00303 int nb_set_acc_cond();
00304
00306 duplicator_node_delayed* add_duplicator_node_delayed(const spot::state* sn,
00307 const spot::state* dn,
00308 bdd acc,
00309 bdd label,
00310 int nb);
00311
00313 spoiler_node_delayed* add_spoiler_node_delayed(const spot::state* sn,
00314 const spot::state* dn,
00315 bdd acc,
00316 int nb);
00317
00318 void build_recurse_successor_spoiler(spoiler_node* sn,
00319 std::ostringstream& os);
00320 void build_recurse_successor_duplicator(duplicator_node* dn,
00321 spoiler_node* sn,
00322 std::ostringstream& os);
00323
00325 virtual void build_graph();
00326
00328 virtual void lift();
00329
00330 };
00331
00333 }
00334
00335 #endif // SPOT_TGBAALGOS_REDUCTGBA_SIM_HH