spot  1.99.3
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
bdddict.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2011, 2012, 2013, 2014, 2015 Laboratoire de Recherche
3 // et Développement de l'Epita (LRDE).
4 // Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de Paris
5 // 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
6 // Université Pierre et Marie Curie.
7 //
8 // This file is part of Spot, a model checking library.
9 //
10 // Spot is free software; you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Spot is distributed in the hope that it will be useful, but WITHOUT
16 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 // License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 #pragma once
24 
25 #include <list>
26 #include <set>
27 #include <map>
28 #include <iosfwd>
29 #include <bddx.h>
30 #include <vector>
31 #include <memory>
32 #include "ltlast/formula.hh"
33 
34 namespace spot
35 {
37  class bdd_dict_priv;
38 
55  class SPOT_API bdd_dict
56  {
57  bdd_dict_priv* priv_;
58  public:
59 
60  bdd_dict();
61 
66  ~bdd_dict();
67 
69  typedef std::map<const ltl::formula*, int> fv_map;
71  typedef std::map<int, const ltl::formula*> vf_map;
72 
73  fv_map var_map;
74  fv_map acc_map;
75 
77  typedef std::set<const void*> ref_set;
78 
79  enum var_type { anon = 0, var, acc };
80  struct bdd_info {
81  bdd_info() : type(anon) {}
82  var_type type;
83  const ltl::formula* f; // Used unless t==anon.
84  ref_set refs;
85  int clone_counts;
86  };
87  typedef std::vector<bdd_info> bdd_info_map;
88  // Map BDD variables to their meaning.
89  bdd_info_map bdd_map;
90 
102  int register_proposition(const ltl::formula* f, const void* for_me);
103 
104  template <typename T>
105  int register_proposition(const ltl::formula* f,
106  std::shared_ptr<T> for_me)
107  {
108  return register_proposition(f, for_me.get());
109  }
111 
120  void register_propositions(bdd f, const void* for_me);
121 
122  template <typename T>
123  void register_propositions(bdd f, std::shared_ptr<T> for_me)
124  {
125  register_propositions(f, for_me.get());
126  }
128 
135  int has_registered_proposition(const ltl::formula* f,
136  const void* me);
137  template <typename T>
138  int has_registered_proposition(const ltl::formula* f,
139  std::shared_ptr<T> for_me)
140  {
141  return has_registered_proposition(f, for_me.get());
142  }
144 
156  int register_acceptance_variable(const ltl::formula* f, const void* for_me);
157 
158  template <typename T>
159  int register_acceptance_variable(const ltl::formula* f,
160  std::shared_ptr<T> for_me)
161  {
162  return register_acceptance_variable(f, for_me.get());
163  }
165 
174  void register_acceptance_variables(bdd f, const void* for_me);
175 
176  template <typename T>
177  void register_acceptance_variables(bdd f, std::shared_ptr<T> for_me)
178  {
179  register_acceptance_variables(f, for_me.get());
180  }
182 
192  const ltl::formula* oneacc_to_formula(bdd oneacc) const;
193 
202  const ltl::formula* oneacc_to_formula(int var) const;
203 
212  int register_anonymous_variables(int n, const void* for_me);
213 
214  template <typename T>
215  int register_anonymous_variables(int n, std::shared_ptr<T> for_me)
216  {
217  return register_anonymous_variables(n, for_me.get());
218  }
220 
228  void register_all_variables_of(const void* from_other, const void* for_me);
229 
230  template <typename T>
231  void register_all_variables_of(const void* from_other,
232  std::shared_ptr<T> for_me)
233  {
234  register_all_variables_of(from_other, for_me.get());
235  }
236 
237  template <typename T>
238  void register_all_variables_of(std::shared_ptr<T> from_other,
239  const void* for_me)
240  {
241  register_all_variables_of(from_other.get(), for_me);
242  }
243 
244  template <typename T, typename U>
245  void register_all_variables_of(std::shared_ptr<T> from_other,
246  std::shared_ptr<U> for_me)
247  {
248  register_all_variables_of(from_other.get(), for_me.get());
249  }
251 
260  void register_all_propositions_of(const void* from_other,
261  const void* for_me);
262 
263  template <typename T>
264  void register_all_propositions_of(const void* from_other,
265  std::shared_ptr<T> for_me)
266  {
267  register_all_propositions_of(from_other, for_me.get());
268  }
269 
270  template <typename T>
271  void register_all_propositions_of(std::shared_ptr<T> from_other,
272  const void* for_me)
273  {
274  register_all_propositions_of(from_other.get(), for_me);
275  }
276 
277  template <typename T, typename U>
278  void register_all_propositions_of(std::shared_ptr<T> from_other,
279  std::shared_ptr<U> for_me)
280  {
281  register_all_propositions_of(from_other.get(), for_me.get());
282  }
284 
288  void unregister_all_my_variables(const void* me);
289 
293  void unregister_all_typed_variables(var_type type, const void* me);
294 
295  template <typename T>
296  void unregister_all_typed_variables(var_type type, std::shared_ptr<T> me)
297  {
298  unregister_all_typed_variables(type, me.get());
299  }
301 
304  void unregister_variable(int var, const void* me);
305 
306  template <typename T>
307  void unregister_variable(int var, std::shared_ptr<T> me)
308  {
309  unregister_variable(var, me.get());
310  }
312 
315  std::ostream& dump(std::ostream& os) const;
316 
328  void assert_emptiness() const;
329 
330  private:
331  // Disallow copy.
332  bdd_dict(const bdd_dict& other) SPOT_DELETED;
333  bdd_dict& operator=(const bdd_dict& other) SPOT_DELETED;
334  };
335 
336  typedef std::shared_ptr<bdd_dict> bdd_dict_ptr;
337 
338  inline bdd_dict_ptr make_bdd_dict()
339  {
340  return std::make_shared<bdd_dict>();
341  }
342 }
std::set< const void * > ref_set
BDD-variable reference counts.
Definition: bdddict.hh:77
Definition: public.hh:31
fv_map acc_map
Maps acceptance conditions to BDD variables.
Definition: bdddict.hh:74
LTL formula interface.
std::map< const ltl::formula *, int > fv_map
Formula-to-BDD-variable maps.
Definition: bdddict.hh:69
Definition: bdddict.hh:80
Map BDD variables to formulae.
Definition: bdddict.hh:55
SPOT_API std::ostream & dump(std::ostream &os, const formula *f)
Dump a formula tree.
std::map< int, const ltl::formula * > vf_map
BDD-variable-to-formula maps.
Definition: bdddict.hh:71
An LTL formula.
Definition: formula.hh:71
fv_map var_map
Maps atomic propositions to BDD variables.
Definition: bdddict.hh:73

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Wed Aug 26 2015 08:42:37 for spot by doxygen 1.8.8