spot
0.9.1
|
00001 // -*- coding: utf-8 -*- 00002 // Copyright (C) 2011, 2012 Laboratoire de Recherche et Développement 00003 // de l'Epita (LRDE). 00004 // Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de Paris 6 (LIP6), 00005 // département Systèmes Répartis Coopératifs (SRC), Université Pierre 00006 // et Marie Curie. 00007 // 00008 // This file is part of Spot, a model checking library. 00009 // 00010 // Spot is free software; you can redistribute it and/or modify it 00011 // under the terms of the GNU General Public License as published by 00012 // the Free Software Foundation; either version 2 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // Spot is distributed in the hope that it will be useful, but WITHOUT 00016 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00017 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00018 // License for more details. 00019 // 00020 // You should have received a copy of the GNU General Public License 00021 // along with Spot; see the file COPYING. If not, write to the Free 00022 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00023 // 02111-1307, USA. 00024 00025 #ifndef SPOT_TGBA_BDDDICT_HH 00026 # define SPOT_TGBA_BDDDICT_HH 00027 00028 #include <list> 00029 #include <set> 00030 #include <map> 00031 #include <iosfwd> 00032 #include <bdd.h> 00033 #include <vector> 00034 #include "ltlast/formula.hh" 00035 #include "misc/bddalloc.hh" 00036 00037 namespace spot 00038 { 00039 00049 class bdd_dict: public bdd_allocator 00050 { 00051 public: 00052 00053 bdd_dict(); 00054 ~bdd_dict(); 00055 00057 typedef std::map<const ltl::formula*, int> fv_map; 00059 typedef std::map<int, const ltl::formula*> vf_map; 00060 00061 fv_map now_map; 00062 fv_map var_map; 00063 fv_map acc_map; 00064 00066 typedef std::set<const void*> ref_set; 00067 00068 enum var_type { anon = 0, now, next, var, acc }; 00069 struct bdd_info { 00070 bdd_info() : type(anon) {} 00071 var_type type; 00072 const ltl::formula* f; // Used unless t==anon. 00073 ref_set refs; 00074 int clone_counts; 00075 }; 00076 typedef std::vector<bdd_info> bdd_info_map; 00077 // Map BDD variables to their meaning. 00078 bdd_info_map bdd_map; 00079 00083 bddPair* next_to_now; 00087 bddPair* now_to_next; 00088 00099 int register_proposition(const ltl::formula* f, const void* for_me); 00100 00108 void register_propositions(bdd f, const void* for_me); 00109 00121 int register_state(const ltl::formula* f, const void* for_me); 00122 00133 int register_acceptance_variable(const ltl::formula* f, const void* for_me); 00134 00140 int register_clone_acc(int var, const void* for_me); 00141 00149 void register_acceptance_variables(bdd f, const void* for_me); 00150 00160 const ltl::formula* oneacc_to_formula(bdd oneacc) const; 00161 00170 const ltl::formula* oneacc_to_formula(int var) const; 00171 00179 int register_anonymous_variables(int n, const void* for_me); 00180 00187 void register_all_variables_of(const void* from_other, const void* for_me); 00188 00192 void unregister_all_my_variables(const void* me); 00193 00195 void unregister_variable(int var, const void* me); 00196 00199 bool is_registered_proposition(const ltl::formula* f, const void* by_me); 00200 bool is_registered_state(const ltl::formula* f, const void* by_me); 00201 bool is_registered_acceptance_variable(const ltl::formula* f, 00202 const void* by_me); 00204 00207 std::ostream& dump(std::ostream& os) const; 00208 00213 void assert_emptiness() const; 00214 00215 protected: 00216 // SWIG does not grok the following definition, no idea why. 00217 // It's not important for the Python interface anyway. 00218 #ifndef SWIG 00219 class anon_free_list : public spot::free_list 00220 { 00221 public: 00222 // WARNING: We need a default constructor so this can be used in 00223 // a hash; but we should ensure that no object in the hash is 00224 // constructed with d==0. 00225 anon_free_list(bdd_dict* d = 0); 00226 virtual int extend(int n); 00227 private: 00228 bdd_dict* dict_; 00229 }; 00230 #endif 00231 00233 typedef std::map<const void*, anon_free_list> free_anonymous_list_of_type; 00234 free_anonymous_list_of_type free_anonymous_list_of; 00235 00236 private: 00237 // Disallow copy. 00238 bdd_dict(const bdd_dict& other); 00239 bdd_dict& operator=(const bdd_dict& other); 00240 }; 00241 00242 00243 } 00244 00245 #endif // SPOT_TGBA_BDDDICT_HH