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
00072
00073
00074 delayed_simulation_relation* get_delayed_relation_simulation(const tgba* a,
00075 std::ostream& os,
00076 int opt = -1);
00077
00079 void free_relation_simulation(direct_simulation_relation* rel);
00081 void free_relation_simulation(delayed_simulation_relation* rel);
00082
00084
00085
00086 class spoiler_node;
00087 class duplicator_node;
00088
00089 typedef Sgi::vector<spoiler_node*> sn_v;
00090 typedef Sgi::vector<duplicator_node*> dn_v;
00091 typedef Sgi::vector<const state*> s_v;
00092
00094 class parity_game_graph : public tgba_reachable_iterator_breadth_first
00095 {
00096 public:
00097 parity_game_graph(const tgba* a);
00098 virtual ~parity_game_graph();
00099
00100 virtual simulation_relation* get_relation() = 0;
00101
00102 void print(std::ostream& os);
00103
00104 protected:
00105 sn_v spoiler_vertice_;
00106 dn_v duplicator_vertice_;
00107 s_v tgba_state_;
00108 int nb_node_parity_game;
00109
00110 void start();
00111 void end();
00112 void process_state(const state* s, int n, tgba_succ_iterator* si);
00113 void process_link(int in, int out, const tgba_succ_iterator* si);
00114
00116 virtual void build_graph() = 0;
00117
00122 virtual void lift() = 0;
00123 };
00124
00126
00127
00129 class spoiler_node
00130 {
00131 public:
00132 spoiler_node(const state* d_node,
00133 const state* s_node,
00134 int num);
00135 virtual ~spoiler_node();
00136
00140 bool add_succ(spoiler_node* n);
00141 void del_succ(spoiler_node* n);
00142 virtual void add_pred(spoiler_node* n);
00143 virtual void del_pred();
00144 int get_nb_succ();
00145 bool prune();
00146 virtual bool set_win();
00147 virtual std::string to_string(const tgba* a);
00148 virtual std::string succ_to_string();
00149 virtual bool compare(spoiler_node* n);
00150
00151 const state* get_spoiler_node();
00152 const state* get_duplicator_node();
00153 state_couple* get_pair();
00154
00155 bool not_win;
00156 int num_;
00157
00158 protected:
00159 sn_v* lnode_succ;
00160 sn_v* lnode_pred;
00161 state_couple* sc_;
00162 };
00163
00165 class duplicator_node : public spoiler_node
00166 {
00167 public:
00168 duplicator_node(const state* d_node,
00169 const state* s_node,
00170 bdd l,
00171 bdd a,
00172 int num);
00173 virtual ~duplicator_node();
00174
00175 virtual bool set_win();
00176 virtual std::string to_string(const tgba* a);
00177 virtual bool compare(spoiler_node* n);
00178
00179 bool match(bdd l, bdd a);
00180 bool implies(bdd l, bdd a);
00181
00182 bdd get_label() const;
00183 bdd get_acc() const;
00184
00185 protected:
00186 bdd label_;
00187 bdd acc_;
00188 };
00189
00191 class parity_game_graph_direct : public parity_game_graph
00192 {
00193 public:
00194 parity_game_graph_direct(const tgba* a);
00195 ~parity_game_graph_direct();
00196
00197 virtual direct_simulation_relation* get_relation();
00198
00199 protected:
00200 virtual void build_graph();
00201 virtual void lift();
00202 void build_link();
00203
00204 };
00205
00206
00208
00209
00211 class spoiler_node_delayed : public spoiler_node
00212 {
00213 public:
00214 spoiler_node_delayed(const state* d_node,
00215 const state* s_node,
00216 bdd a,
00217 int num);
00218 ~spoiler_node_delayed();
00219
00221 bool set_win();
00222 bdd get_acceptance_condition_visited() const;
00223 virtual bool compare(spoiler_node* n);
00224 virtual std::string to_string(const tgba* a);
00225 int get_progress_measure() const;
00226
00227 bool get_lead_2_acc_all();
00228 bool set_lead_2_acc_all(bdd acc = bddfalse);
00229
00230
00231 bool seen_;
00232 protected:
00235 bdd acceptance_condition_visited_;
00236 int progress_measure_;
00237 bool lead_2_acc_all_;
00238 };
00239
00241 class duplicator_node_delayed : public duplicator_node
00242 {
00243 public:
00244 duplicator_node_delayed(const state* d_node,
00245 const state* s_node,
00246 bdd l,
00247 bdd a,
00248 int num);
00249 ~duplicator_node_delayed();
00250
00252 bool set_win();
00253 virtual std::string to_string(const tgba* a);
00254 bool implies_label(bdd l);
00255 bool implies_acc(bdd a);
00256 int get_progress_measure();
00257
00258 bool get_lead_2_acc_all();
00259 bool set_lead_2_acc_all(bdd acc = bddfalse);
00260
00261
00262 bool seen_;
00263 protected:
00264 int progress_measure_;
00265 bool lead_2_acc_all_;
00266 };
00267
00268
00288 class parity_game_graph_delayed: public parity_game_graph
00289 {
00290 public:
00291 parity_game_graph_delayed(const tgba* a);
00292 ~parity_game_graph_delayed();
00293
00294 virtual delayed_simulation_relation* get_relation();
00295
00296 private:
00297
00300 typedef Sgi::vector<bdd> bdd_v;
00301 bdd_v sub_set_acc_cond_;
00302
00304 int nb_set_acc_cond();
00305
00307 duplicator_node_delayed* add_duplicator_node_delayed(const spot::state* sn,
00308 const spot::state* dn,
00309 bdd acc,
00310 bdd label,
00311 int nb);
00312
00314 spoiler_node_delayed* add_spoiler_node_delayed(const spot::state* sn,
00315 const spot::state* dn,
00316 bdd acc,
00317 int nb);
00318
00319 void build_recurse_successor_spoiler(spoiler_node* sn,
00320 std::ostringstream& os);
00321 void build_recurse_successor_duplicator(duplicator_node* dn,
00322 spoiler_node* sn,
00323 std::ostringstream& os);
00324
00326 virtual void build_graph();
00327
00329 virtual void lift();
00330
00331 };
00332
00334 }
00335
00336 #endif // SPOT_TGBAALGOS_REDUCTGBA_SIM_HH