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_REDUC_TGBA_SIM_HH
00024
#define SPOT_REDUC_TGBA_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
00036 enum reduce_tgba_options
00037 {
00039 Reduce_None = 0,
00041
Reduce_Dir_Sim = 1,
00043
Reduce_Del_Sim = 2,
00045
Reduce_Scc = 4,
00047 Reduce_All = -1U
00048 };
00049
00055
00057 tgba*
reduc_tgba_sim(
const tgba* a,
int opt = Reduce_All);
00058
00060 simulation_relation*
get_direct_relation_simulation(
const tgba* a,
00061
int opt = -1);
00062
00066 simulation_relation*
get_delayed_relation_simulation(
const tgba* a,
00067
int opt = -1);
00068
00070
void free_relation_simulation(simulation_relation* rel);
00071
00074
bool is_include(
const tgba* a1,
const tgba* a2);
00075
00077
00078
00079
class spoiler_node;
00080
class duplicator_node;
00081
00082 typedef Sgi::vector<spoiler_node*>
sn_v;
00083 typedef Sgi::vector<duplicator_node*>
dn_v;
00084 typedef Sgi::vector<const state*>
s_v;
00085
00087 class parity_game_graph :
public tgba_reachable_iterator_breadth_first
00088 {
00089
public:
00090
parity_game_graph(
const tgba* a);
00091
virtual ~parity_game_graph();
00092
00093
virtual simulation_relation*
get_relation() = 0;
00094
00095
void print(std::ostream& os);
00096
00097
protected:
00098 sn_v spoiler_vertice_;
00099 dn_v duplicator_vertice_;
00100 s_v tgba_state_;
00101 int nb_node_parity_game;
00102
00103
void start();
00104
void end();
00105
void process_state(
const state* s,
int n,
tgba_succ_iterator* si);
00106
void process_link(
int in,
int out,
const tgba_succ_iterator* si);
00107
00109
virtual void build_graph() = 0;
00110
00114
00115
00120
virtual void lift() = 0;
00121 };
00122
00124
00125
00127 class spoiler_node
00128 {
00129
public:
00130
spoiler_node(
const state* d_node,
00131
const state* s_node,
00132
int num);
00133
virtual ~spoiler_node();
00134
00138
bool add_succ(
spoiler_node* n);
00139
void del_succ(
spoiler_node* n);
00140
virtual void add_pred(
spoiler_node* n);
00141
virtual void del_pred();
00142
int get_nb_succ();
00143
bool prune();
00144
virtual bool set_win();
00145
virtual std::string
to_string(
const tgba* a);
00146
virtual std::string
succ_to_string();
00147
virtual bool compare(
spoiler_node* n);
00148
00149
const state*
get_spoiler_node();
00150
const state*
get_duplicator_node();
00151
state_couple*
get_pair();
00152
00153 bool not_win;
00154 int num_;
00155
00156
protected:
00157 sn_v*
lnode_succ;
00158 sn_v*
lnode_pred;
00159
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 simulation_relation*
get_relation();
00197
00198
protected:
00199
virtual void build_graph();
00200
virtual void lift();
00201
void build_link();
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 };
00221
00222
00224
00225
00227 class spoiler_node_delayed :
public spoiler_node
00228 {
00229
public:
00230
spoiler_node_delayed(
const state* d_node,
00231
const state* s_node,
00232 bdd a,
00233
int num,
00234
bool l2a =
true);
00235
~spoiler_node_delayed();
00236
00238
bool set_win();
00239 bdd
get_acceptance_condition_visited()
const;
00240
virtual bool compare(
spoiler_node* n);
00241
virtual std::string
to_string(
const tgba* a);
00242
int get_progress_measure()
const;
00243
00244
bool get_lead_2_acc_all();
00245
00246
00247
00248
protected:
00251 bdd
acceptance_condition_visited_;
00252 int progress_measure_;
00253 bool lead_2_acc_all_;
00254
00255 };
00256
00258 class duplicator_node_delayed :
public duplicator_node
00259 {
00260
public:
00261
duplicator_node_delayed(
const state* d_node,
00262
const state* s_node,
00263 bdd l,
00264 bdd a,
00265
int num);
00266
~duplicator_node_delayed();
00267
00269
bool set_win();
00270
virtual std::string
to_string(
const tgba* a);
00271
bool implies_label(bdd l);
00272
bool implies_acc(bdd a);
00273
int get_progress_measure();
00274
bool get_lead_2_acc_all();
00275
void set_lead_2_acc_all();
00276
00277
protected:
00278 int progress_measure_;
00279 bool lead_2_acc_all_;
00280 };
00281
00300
00301 class parity_game_graph_delayed :
public parity_game_graph
00302 {
00303
public:
00304
parity_game_graph_delayed(
const tgba* a);
00305
~parity_game_graph_delayed();
00306
00307
virtual simulation_relation*
get_relation();
00308
00309
private:
00310
00313 typedef Sgi::vector<bdd>
bdd_v;
00314 bdd_v sub_set_acc_cond_;
00315
00317
int nb_set_acc_cond();
00318
00320
void build_sub_set_acc_cond();
00321
00323
duplicator_node_delayed*
add_duplicator_node_delayed(
const spot::state* sn,
00324
const spot::state* dn,
00325 bdd acc,
00326 bdd label,
00327
int nb);
00328
00330
spoiler_node_delayed*
add_spoiler_node_delayed(
const spot::state* sn,
00331
const spot::state* dn,
00332 bdd acc,
00333
int nb);
00334
00336
virtual void build_graph();
00337
00338
00339
void build_recurse_successor_spoiler(
spoiler_node* sn,
00340 std::ostringstream& os);
00341
void build_recurse_successor_duplicator(
duplicator_node* dn,
00342
spoiler_node* sn,
00343 std::ostringstream& os);
00344
00346
virtual void lift();
00347
00349
00350 };
00351
00352 }
00353
00354
#endif