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
00057 tgba*
reduc_tgba_sim(
const tgba* a,
int opt = Reduce_All);
00058
00060 simulation_relation*
get_direct_relation_simulation(
const tgba* a,
00061 std::ostream& os,
00062
int opt = -1);
00063
00065
00066
00067 simulation_relation*
get_delayed_relation_simulation(
const tgba* a,
00068 std::ostream& os,
00069
int opt = -1);
00070
00072
void free_relation_simulation(simulation_relation* rel);
00073
00075
00076
00077
class spoiler_node;
00078
class duplicator_node;
00079
00080 typedef Sgi::vector<spoiler_node*>
sn_v;
00081 typedef Sgi::vector<duplicator_node*>
dn_v;
00082 typedef Sgi::vector<const state*>
s_v;
00083
00085 class parity_game_graph :
public tgba_reachable_iterator_breadth_first
00086 {
00087
public:
00088
parity_game_graph(
const tgba* a);
00089
virtual ~parity_game_graph();
00090
00091
virtual simulation_relation*
get_relation() = 0;
00092
00093
void print(std::ostream& os);
00094
00095
protected:
00096 sn_v spoiler_vertice_;
00097 dn_v duplicator_vertice_;
00098 s_v tgba_state_;
00099 int nb_node_parity_game;
00100
00101
void start();
00102
void end();
00103
void process_state(
const state* s,
int n,
tgba_succ_iterator* si);
00104
void process_link(
int in,
int out,
const tgba_succ_iterator* si);
00105
00107
virtual void build_graph() = 0;
00108
00113
virtual void lift() = 0;
00114 };
00115
00117
00118
00120 class spoiler_node
00121 {
00122
public:
00123
spoiler_node(
const state* d_node,
00124
const state* s_node,
00125
int num);
00126
virtual ~spoiler_node();
00127
00131
bool add_succ(
spoiler_node* n);
00132
void del_succ(
spoiler_node* n);
00133
virtual void add_pred(
spoiler_node* n);
00134
virtual void del_pred();
00135
int get_nb_succ();
00136
bool prune();
00137
virtual bool set_win();
00138
virtual std::string
to_string(
const tgba* a);
00139
virtual std::string
succ_to_string();
00140
virtual bool compare(
spoiler_node* n);
00141
00142
const state*
get_spoiler_node();
00143
const state*
get_duplicator_node();
00144
state_couple*
get_pair();
00145
00146 bool not_win;
00147 int num_;
00148
00149
protected:
00150 sn_v*
lnode_succ;
00151 sn_v*
lnode_pred;
00152 state_couple*
sc_;
00153 };
00154
00156 class duplicator_node :
public spoiler_node
00157 {
00158
public:
00159
duplicator_node(
const state* d_node,
00160
const state* s_node,
00161 bdd l,
00162 bdd a,
00163
int num);
00164
virtual ~duplicator_node();
00165
00166
virtual bool set_win();
00167
virtual std::string
to_string(
const tgba* a);
00168
virtual bool compare(
spoiler_node* n);
00169
00170
bool match(bdd l, bdd a);
00171
bool implies(bdd l, bdd a);
00172
00173 bdd
get_label()
const;
00174 bdd
get_acc()
const;
00175
00176
protected:
00177 bdd
label_;
00178 bdd
acc_;
00179 };
00180
00182 class parity_game_graph_direct :
public parity_game_graph
00183 {
00184
public:
00185
parity_game_graph_direct(
const tgba* a);
00186
~parity_game_graph_direct();
00187
00188
virtual simulation_relation*
get_relation();
00189
00190
protected:
00191
virtual void build_graph();
00192
virtual void lift();
00193
void build_link();
00194
00195 };
00196
00197
00199
00200
00202 class spoiler_node_delayed :
public spoiler_node
00203 {
00204
public:
00205
spoiler_node_delayed(
const state* d_node,
00206
const state* s_node,
00207 bdd a,
00208
int num);
00209
~spoiler_node_delayed();
00210
00212
bool set_win();
00213 bdd
get_acceptance_condition_visited()
const;
00214
virtual bool compare(
spoiler_node* n);
00215
virtual std::string
to_string(
const tgba* a);
00216
int get_progress_measure()
const;
00217
00218
bool get_lead_2_acc_all();
00219
bool set_lead_2_acc_all(bdd acc = bddfalse);
00220
00221
00222 bool seen_;
00223
protected:
00226 bdd
acceptance_condition_visited_;
00227 int progress_measure_;
00228 bool lead_2_acc_all_;
00229 };
00230
00232 class duplicator_node_delayed :
public duplicator_node
00233 {
00234
public:
00235
duplicator_node_delayed(
const state* d_node,
00236
const state* s_node,
00237 bdd l,
00238 bdd a,
00239
int num);
00240
~duplicator_node_delayed();
00241
00243
bool set_win();
00244
virtual std::string
to_string(
const tgba* a);
00245
bool implies_label(bdd l);
00246
bool implies_acc(bdd a);
00247
int get_progress_measure();
00248
00249
bool get_lead_2_acc_all();
00250
bool set_lead_2_acc_all(bdd acc = bddfalse);
00251
00252
00253 bool seen_;
00254
protected:
00255 int progress_measure_;
00256 bool lead_2_acc_all_;
00257 };
00258
00259
00279 class parity_game_graph_delayed:
public parity_game_graph
00280 {
00281
public:
00282
parity_game_graph_delayed(
const tgba* a);
00283
~parity_game_graph_delayed();
00284
00285
virtual simulation_relation*
get_relation();
00286
00287
private:
00288
00291 typedef Sgi::vector<bdd>
bdd_v;
00292 bdd_v sub_set_acc_cond_;
00293
00295
int nb_set_acc_cond();
00296
00298
duplicator_node_delayed*
add_duplicator_node_delayed(
const spot::state* sn,
00299
const spot::state* dn,
00300 bdd acc,
00301 bdd label,
00302
int nb);
00303
00305
spoiler_node_delayed*
add_spoiler_node_delayed(
const spot::state* sn,
00306
const spot::state* dn,
00307 bdd acc,
00308
int nb);
00309
00310
void build_recurse_successor_spoiler(
spoiler_node* sn,
00311 std::ostringstream& os);
00312
void build_recurse_successor_duplicator(
duplicator_node* dn,
00313
spoiler_node* sn,
00314 std::ostringstream& os);
00315
00317
virtual void build_graph();
00318
00320
virtual void lift();
00321
00322 };
00323
00324 }
00325
00326
#endif