reductgba_sim.hh

Go to the documentation of this file.
00001 // Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
00002 // 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 start();
00120     void end();
00121     void process_state(const state* s, int n, tgba_succ_iterator* si);
00122     void process_link(int in, int out, const tgba_succ_iterator* si);
00123 
00125     virtual void build_graph() = 0;
00126 
00131     virtual void lift() = 0;
00132   };
00133 
00135   // Direct simulation.
00136 
00138   class spoiler_node
00139   {
00140   public:
00141     spoiler_node(const state* d_node,
00142                  const state* s_node,
00143                  int num);
00144     virtual ~spoiler_node();
00145 
00149     bool add_succ(spoiler_node* n);
00150     void del_succ(spoiler_node* n);
00151     virtual void add_pred(spoiler_node* n);
00152     virtual void del_pred();
00153     int get_nb_succ();
00154     bool prune();
00155     virtual bool set_win();
00156     virtual std::string to_string(const tgba* a);
00157     virtual std::string succ_to_string();
00158     virtual bool compare(spoiler_node* n);
00159 
00160     const state* get_spoiler_node();
00161     const state* get_duplicator_node();
00162     state_couple* get_pair();
00163 
00164     bool not_win;
00165     int num_; // for the dot display.
00166 
00167   protected:
00168     sn_v* lnode_succ;
00169     sn_v* lnode_pred;
00170     state_couple* sc_;
00171   };
00172 
00174   class duplicator_node : public spoiler_node
00175   {
00176   public:
00177     duplicator_node(const state* d_node,
00178                     const state* s_node,
00179                     bdd l,
00180                     bdd a,
00181                     int num);
00182     virtual ~duplicator_node();
00183 
00184     virtual bool set_win();
00185     virtual std::string to_string(const tgba* a);
00186     virtual bool compare(spoiler_node* n);
00187 
00188     bool match(bdd l, bdd a);
00189     bool implies(bdd l, bdd a);
00190 
00191     bdd get_label() const;
00192     bdd get_acc() const;
00193 
00194   protected:
00195     bdd label_;
00196     bdd acc_;
00197   };
00198 
00200   class parity_game_graph_direct : public parity_game_graph
00201   {
00202   public:
00203     parity_game_graph_direct(const tgba* a);
00204     ~parity_game_graph_direct();
00205 
00206     virtual direct_simulation_relation* get_relation();
00207 
00208   protected:
00209     virtual void build_graph();
00210     virtual void lift();
00211     void build_link();
00212 
00213   };
00214 
00215 
00217   // Delayed simulation.
00218 
00220   class spoiler_node_delayed : public spoiler_node
00221   {
00222   public:
00223     spoiler_node_delayed(const state* d_node,
00224                          const state* s_node,
00225                          bdd a,
00226                          int num);
00227     ~spoiler_node_delayed();
00228 
00230     bool set_win();
00231     bdd get_acceptance_condition_visited() const;
00232     virtual bool compare(spoiler_node* n);
00233     virtual std::string to_string(const tgba* a);
00234     int get_progress_measure() const;
00235 
00236     bool get_lead_2_acc_all();
00237     bool set_lead_2_acc_all(bdd acc = bddfalse);
00238 
00239     //
00240     bool seen_;
00241   protected:
00244     bdd acceptance_condition_visited_;
00245     int progress_measure_;
00246     bool lead_2_acc_all_;
00247   };
00248 
00250   class duplicator_node_delayed : public duplicator_node
00251   {
00252   public:
00253     duplicator_node_delayed(const state* d_node,
00254                             const state* s_node,
00255                             bdd l,
00256                             bdd a,
00257                             int num);
00258     ~duplicator_node_delayed();
00259 
00261     bool set_win();
00262     virtual std::string to_string(const tgba* a);
00263     bool implies_label(bdd l);
00264     bool implies_acc(bdd a);
00265     int get_progress_measure();
00266 
00267     bool get_lead_2_acc_all();
00268     bool set_lead_2_acc_all(bdd acc = bddfalse);
00269 
00270     //
00271     bool seen_;
00272   protected:
00273     int progress_measure_;
00274     bool lead_2_acc_all_;
00275   };
00276 
00277 
00297   class parity_game_graph_delayed: public parity_game_graph
00298   {
00299   public:
00300     parity_game_graph_delayed(const tgba* a);
00301     ~parity_game_graph_delayed();
00302 
00303     virtual delayed_simulation_relation* get_relation();
00304 
00305   private:
00306 
00309     typedef std::vector<bdd> bdd_v;
00310     bdd_v sub_set_acc_cond_;
00311 
00313     int nb_set_acc_cond();
00314 
00316     duplicator_node_delayed* add_duplicator_node_delayed(const spot::state* sn,
00317                                                          const spot::state* dn,
00318                                                          bdd acc,
00319                                                          bdd label,
00320                                                          int nb);
00321 
00323     spoiler_node_delayed* add_spoiler_node_delayed(const spot::state* sn,
00324                                                    const spot::state* dn,
00325                                                    bdd acc,
00326                                                    int nb);
00327 
00328     void build_recurse_successor_spoiler(spoiler_node* sn,
00329                                          std::ostringstream& os);
00330     void build_recurse_successor_duplicator(duplicator_node* dn,
00331                                             spoiler_node* sn,
00332                                             std::ostringstream& os);
00333 
00335     virtual void build_graph();
00336 
00338     virtual void lift();
00339   };
00340 
00341 #endif // SWIG
00342 
00344 }
00345 
00346 #endif // SPOT_TGBAALGOS_REDUCTGBA_SIM_HH

Please comment this page and report errors about it on the RefDocComments page.
Generated on Fri Apr 16 09:40:33 2010 for spot by doxygen 1.6.3