spot  1.99.1
 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 
172  int register_clone_acc(int var, const void* for_me);
173 
174  template <typename T>
175  int register_clone_acc(int var, std::shared_ptr<T> for_me)
176  {
177  return register_clone_acc(var, for_me.get());
178  }
180 
189  void register_acceptance_variables(bdd f, const void* for_me);
190 
191  template <typename T>
192  void register_acceptance_variables(bdd f, std::shared_ptr<T> for_me)
193  {
194  register_acceptance_variables(f, for_me.get());
195  }
197 
207  const ltl::formula* oneacc_to_formula(bdd oneacc) const;
208 
217  const ltl::formula* oneacc_to_formula(int var) const;
218 
227  int register_anonymous_variables(int n, const void* for_me);
228 
229  template <typename T>
230  int register_anonymous_variables(int n, std::shared_ptr<T> for_me)
231  {
232  return register_anonymous_variables(n, for_me.get());
233  }
235 
243  void register_all_variables_of(const void* from_other, const void* for_me);
244 
245  template <typename T>
246  void register_all_variables_of(const void* from_other,
247  std::shared_ptr<T> for_me)
248  {
249  register_all_variables_of(from_other, for_me.get());
250  }
251 
252  template <typename T>
253  void register_all_variables_of(std::shared_ptr<T> from_other,
254  const void* for_me)
255  {
256  register_all_variables_of(from_other.get(), for_me);
257  }
258 
259  template <typename T, typename U>
260  void register_all_variables_of(std::shared_ptr<T> from_other,
261  std::shared_ptr<U> for_me)
262  {
263  register_all_variables_of(from_other.get(), for_me.get());
264  }
266 
275  void register_all_propositions_of(const void* from_other,
276  const void* for_me);
277 
278  template <typename T>
279  void register_all_propositions_of(const void* from_other,
280  std::shared_ptr<T> for_me)
281  {
282  register_all_propositions_of(from_other, for_me.get());
283  }
284 
285  template <typename T>
286  void register_all_propositions_of(std::shared_ptr<T> from_other,
287  const void* for_me)
288  {
289  register_all_propositions_of(from_other.get(), for_me);
290  }
291 
292  template <typename T, typename U>
293  void register_all_propositions_of(std::shared_ptr<T> from_other,
294  std::shared_ptr<U> for_me)
295  {
296  register_all_propositions_of(from_other.get(), for_me.get());
297  }
299 
303  void unregister_all_my_variables(const void* me);
304 
308  void unregister_all_typed_variables(var_type type, const void* me);
309 
310  template <typename T>
311  void unregister_all_typed_variables(var_type type, std::shared_ptr<T> me)
312  {
313  unregister_all_typed_variables(type, me.get());
314  }
316 
319  void unregister_variable(int var, const void* me);
320 
321  template <typename T>
322  void unregister_variable(int var, std::shared_ptr<T> me)
323  {
324  unregister_variable(var, me.get());
325  }
327 
330  std::ostream& dump(std::ostream& os) const;
331 
343  void assert_emptiness() const;
344 
345  private:
346  // Disallow copy.
347  bdd_dict(const bdd_dict& other) SPOT_DELETED;
348  bdd_dict& operator=(const bdd_dict& other) SPOT_DELETED;
349  };
350 
351  typedef std::shared_ptr<bdd_dict> bdd_dict_ptr;
352 
353  inline bdd_dict_ptr make_bdd_dict()
354  {
355  return std::make_shared<bdd_dict>();
356  }
357 }
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 Tue Jun 23 2015 06:55:46 for spot by doxygen 1.8.8