Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Bdd.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_DD_BDD_H_
2#define STORM_STORAGE_DD_BDD_H_
3
4#include <functional>
5
8
12
13namespace storm {
14namespace logic {
15enum class ComparisonType;
16}
17
18namespace dd {
19template<DdType LibraryType, typename ValueType>
20class Add;
21
22class Odd;
23
24template<DdType LibraryType>
25class Bdd : public Dd<LibraryType> {
26 public:
27 friend class DdManager<LibraryType>;
28
29 template<DdType LibraryTypePrime, typename ValueTypePrime>
30 friend class Add;
31
39 Bdd(DdManager<LibraryType> const& ddManager, InternalBdd<LibraryType> const& internalBdd,
40 std::set<storm::expressions::Variable> const& containedMetaVariables = std::set<storm::expressions::Variable>());
41
42 // Instantiate all copy/move constructors/assignments with the default implementation.
43 Bdd() = default;
44 Bdd(Bdd<LibraryType> const& other) = default;
45 Bdd& operator=(Bdd<LibraryType> const& other) = default;
46 Bdd(Bdd<LibraryType>&& other) = default;
47 Bdd& operator=(Bdd<LibraryType>&& other) = default;
48
57 static Bdd<LibraryType> getEncoding(DdManager<LibraryType> const& ddManager, uint64_t targetOffset, storm::dd::Odd const& odd,
58 std::set<storm::expressions::Variable> const& metaVariables);
59
68 static Bdd<LibraryType> fromVector(DdManager<LibraryType> const& ddManager, storm::storage::BitVector const& truthValues, storm::dd::Odd const& odd,
69 std::set<storm::expressions::Variable> const& metaVariables);
70
81 template<typename ValueType>
82 static Bdd<LibraryType> fromVector(DdManager<LibraryType> const& ddManager, std::vector<ValueType> const& explicitValues, storm::dd::Odd const& odd,
83 std::set<storm::expressions::Variable> const& metaVariables, storm::logic::ComparisonType comparisonType,
84 ValueType value);
85
92 bool operator==(Bdd<LibraryType> const& other) const;
93
100 bool operator!=(Bdd<LibraryType> const& other) const;
101
111 Bdd<LibraryType> ite(Bdd<LibraryType> const& thenBdd, Bdd<LibraryType> const& elseBdd) const;
112
121 template<typename ValueType>
123
130 Bdd<LibraryType> operator||(Bdd<LibraryType> const& other) const;
131
139
146 Bdd<LibraryType> operator&&(Bdd<LibraryType> const& other) const;
147
155
162 Bdd<LibraryType> iff(Bdd<LibraryType> const& other) const;
163
171
178 Bdd<LibraryType> implies(Bdd<LibraryType> const& other) const;
179
186
193
199 Bdd<LibraryType> existsAbstract(std::set<storm::expressions::Variable> const& metaVariables) const;
200
208 Bdd<LibraryType> existsAbstractRepresentative(std::set<storm::expressions::Variable> const& metaVariables) const;
209
215 Bdd<LibraryType> universalAbstract(std::set<storm::expressions::Variable> const& metaVariables) const;
216
225 Bdd<LibraryType> andExists(Bdd<LibraryType> const& other, std::set<storm::expressions::Variable> const& existentialVariables) const;
226
235 Bdd<LibraryType> constrain(Bdd<LibraryType> const& constraint) const;
236
245 Bdd<LibraryType> restrict(Bdd<LibraryType> const& constraint) const;
246
257 Bdd<LibraryType> relationalProduct(Bdd<LibraryType> const& relation, std::set<storm::expressions::Variable> const& rowMetaVariables,
258 std::set<storm::expressions::Variable> const& columnMetaVariables) const;
259
270 Bdd<LibraryType> inverseRelationalProduct(Bdd<LibraryType> const& relation, std::set<storm::expressions::Variable> const& rowMetaVariables,
271 std::set<storm::expressions::Variable> const& columnMetaVariables) const;
272
284 std::set<storm::expressions::Variable> const& rowMetaVariables,
285 std::set<storm::expressions::Variable> const& columnMetaVariables) const;
286
294 Bdd<LibraryType> swapVariables(std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& metaVariablePairs) const;
295
305 Bdd<LibraryType> renameVariables(std::set<storm::expressions::Variable> const& from, std::set<storm::expressions::Variable> const& to) const;
306
318 Bdd<LibraryType> renameVariablesAbstract(std::set<storm::expressions::Variable> const& from, std::set<storm::expressions::Variable> const& to) const;
319
331 Bdd<LibraryType> renameVariablesConcretize(std::set<storm::expressions::Variable> const& from, std::set<storm::expressions::Variable> const& to) const;
332
338 bool isOne() const;
339
345 bool isZero() const;
346
352 template<typename ValueType>
354
358 std::vector<Bdd<LibraryType>> split(std::set<storm::expressions::Variable> const& variables) const;
359
368
376 std::pair<std::vector<storm::expressions::Expression>, std::unordered_map<uint_fast64_t, storm::expressions::Variable>> toExpression(
378
379 virtual Bdd<LibraryType> getSupport() const override;
380
381 virtual uint_fast64_t getNonZeroCount() const override;
382
383 virtual uint_fast64_t getLeafCount() const override;
384
385 virtual uint_fast64_t getNodeCount() const override;
386
387 virtual uint_fast64_t getIndex() const override;
388
389 virtual uint_fast64_t getLevel() const override;
390
391 virtual void exportToDot(std::string const& filename, bool showVariablesIfPossible = true) const override;
392
393 virtual void exportToText(std::string const& filename) const override;
394
401 static Bdd<LibraryType> getCube(DdManager<LibraryType> const& manager, std::set<storm::expressions::Variable> const& metaVariables);
402
408 Odd createOdd() const;
409
417 template<typename ValueType>
418 std::vector<ValueType> filterExplicitVector(Odd const& odd, std::vector<ValueType> const& values) const;
419
428
433
434 friend struct std::hash<storm::dd::Bdd<LibraryType>>;
435
436 template<DdType LibraryTypePrime, typename ValueType>
437 friend struct FromVectorHelper;
438
439 private:
440 // The internal BDD that depends on the chosen library.
441 InternalBdd<LibraryType> internalBdd;
442};
443} // namespace dd
444} // namespace storm
445
446namespace std {
447template<storm::dd::DdType LibraryType>
448struct hash<storm::dd::Bdd<LibraryType>> {
449 std::size_t operator()(storm::dd::Bdd<LibraryType> const& key) const {
450 return std::hash<storm::dd::InternalBdd<LibraryType>>().operator()(key.internalBdd);
451 }
452};
453} // namespace std
454
455#endif /* STORM_STORAGE_DD_BDD_H_ */
Bdd< LibraryType > renameVariablesAbstract(std::set< storm::expressions::Variable > const &from, std::set< storm::expressions::Variable > const &to) const
Renames the given meta variables in the BDD.
Definition Bdd.cpp:377
virtual uint_fast64_t getLevel() const override
Retrieves the level of the topmost variable in the DD.
Definition Bdd.cpp:537
static Bdd< LibraryType > fromVector(DdManager< LibraryType > const &ddManager, storm::storage::BitVector const &truthValues, storm::dd::Odd const &odd, std::set< storm::expressions::Variable > const &metaVariables)
Constructs a BDD representation of all encodings whose value is true in the given list of truth value...
Definition Bdd.cpp:85
Bdd< LibraryType > existsAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Existentially abstracts from the given meta variables.
Definition Bdd.cpp:178
Bdd< LibraryType > inverseRelationalProduct(Bdd< LibraryType > const &relation, std::set< storm::expressions::Variable > const &rowMetaVariables, std::set< storm::expressions::Variable > const &columnMetaVariables) const
Computes the inverse relational product of the current BDD and the given BDD representing a relation.
Definition Bdd.cpp:246
bool isZero() const
Retrieves whether this DD represents the constant zero function.
Definition Bdd.cpp:547
virtual uint_fast64_t getNonZeroCount() const override
Retrieves the number of encodings that are mapped to a non-zero value.
Definition Bdd.cpp:513
bool operator!=(Bdd< LibraryType > const &other) const
Retrieves whether the two BDDs represent different functions.
Definition Bdd.cpp:108
virtual uint_fast64_t getIndex() const override
Retrieves the index of the topmost variable in the DD.
Definition Bdd.cpp:532
Bdd< LibraryType > & operator&=(Bdd< LibraryType > const &other)
Performs a logical and of the current and the given BDD and assigns it to the current BDD.
Definition Bdd.cpp:145
std::pair< std::vector< storm::expressions::Expression >, std::unordered_map< uint_fast64_t, storm::expressions::Variable > > toExpression(storm::expressions::ExpressionManager &manager) const
Translates the function the BDD is representing to a set of expressions that characterize the functio...
Definition Bdd.cpp:502
Bdd< LibraryType > andExists(Bdd< LibraryType > const &other, std::set< storm::expressions::Variable > const &existentialVariables) const
Computes the logical and of the current and the given BDD and existentially abstracts from the given ...
Definition Bdd.cpp:196
static Bdd< LibraryType > getEncoding(DdManager< LibraryType > const &ddManager, uint64_t targetOffset, storm::dd::Odd const &odd, std::set< storm::expressions::Variable > const &metaVariables)
Constructs the BDD representation of the encoding with the given offset.
Definition Bdd.cpp:94
virtual uint_fast64_t getNodeCount() const override
Retrieves the number of nodes necessary to represent the DD.
Definition Bdd.cpp:527
Bdd< LibraryType > swapVariables(std::vector< std::pair< storm::expressions::Variable, storm::expressions::Variable > > const &metaVariablePairs) const
Swaps the given pairs of meta variables in the BDD.
Definition Bdd.cpp:302
Bdd & operator=(Bdd< LibraryType > &&other)=default
Bdd & operator=(Bdd< LibraryType > const &other)=default
Bdd< LibraryType > & complement()
Logically complements the current BDD.
Definition Bdd.cpp:172
Odd createOdd() const
Creates an ODD based on the current BDD.
Definition Bdd.cpp:571
Bdd< LibraryType > operator&&(Bdd< LibraryType > const &other) const
Performs a logical and of the current and the given BDD.
Definition Bdd.cpp:140
storm::storage::BitVector toVector(storm::dd::Odd const &rowOdd) const
Converts the BDD to a bit vector.
Definition Bdd.cpp:497
Bdd< LibraryType > existsAbstractRepresentative(std::set< storm::expressions::Variable > const &metaVariables) const
Similar to existsAbstract, but does not abstract from the variables but rather picks a valuation of e...
Definition Bdd.cpp:184
static Bdd< LibraryType > getCube(DdManager< LibraryType > const &manager, std::set< storm::expressions::Variable > const &metaVariables)
Retrieves the cube of all given meta variables.
Definition Bdd.cpp:562
Bdd< LibraryType > universalAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Universally abstracts from the given meta variables.
Definition Bdd.cpp:190
virtual Bdd< LibraryType > getSupport() const override
Retrieves the support of the current DD.
Definition Bdd.cpp:508
Add< LibraryType, ValueType > toAdd() const
Converts a BDD to an equivalent ADD.
Definition Bdd.cpp:468
Bdd< LibraryType > constrain(Bdd< LibraryType > const &constraint) const
Computes the constraint of the current BDD with the given constraint.
Definition Bdd.cpp:210
Bdd< LibraryType > & operator|=(Bdd< LibraryType > const &other)
Performs a logical or of the current and the given BDD and assigns it to the current BDD.
Definition Bdd.cpp:133
std::vector< Bdd< LibraryType > > split(std::set< storm::expressions::Variable > const &variables) const
Splits the BDD along the given variables (must be at the top).
Definition Bdd.cpp:473
Bdd< LibraryType > ite(Bdd< LibraryType > const &thenBdd, Bdd< LibraryType > const &elseBdd) const
Performs an if-then-else with the given operands, i.e.
Definition Bdd.cpp:113
Bdd< LibraryType > operator!() const
Logically inverts the current BDD.
Definition Bdd.cpp:167
Bdd< LibraryType > iff(Bdd< LibraryType > const &other) const
Performs a logical iff of the current and the given BDD.
Definition Bdd.cpp:152
virtual void exportToDot(std::string const &filename, bool showVariablesIfPossible=true) const override
Exports the DD to the given file in the dot format.
Definition Bdd.cpp:552
Bdd< LibraryType > renameVariables(std::set< storm::expressions::Variable > const &from, std::set< storm::expressions::Variable > const &to) const
Renames the given meta variables in the BDD.
Definition Bdd.cpp:347
Bdd< LibraryType > inverseRelationalProductWithExtendedRelation(Bdd< LibraryType > const &relation, std::set< storm::expressions::Variable > const &rowMetaVariables, std::set< storm::expressions::Variable > const &columnMetaVariables) const
Computes the inverse relational product of the current BDD and the given BDD representing a relation ...
Definition Bdd.cpp:273
bool isOne() const
Retrieves whether this DD represents the constant one function.
Definition Bdd.cpp:542
Bdd()=default
Bdd< LibraryType > exclusiveOr(Bdd< LibraryType > const &other) const
Performs a logical exclusive-or of the current and the given BDD.
Definition Bdd.cpp:157
Bdd< LibraryType > relationalProduct(Bdd< LibraryType > const &relation, std::set< storm::expressions::Variable > const &rowMetaVariables, std::set< storm::expressions::Variable > const &columnMetaVariables) const
Computes the relational product of the current BDD and the given BDD representing a relation.
Definition Bdd.cpp:220
virtual void exportToText(std::string const &filename) const override
Exports the DD to the given file in the dot format.
Definition Bdd.cpp:557
Bdd(Bdd< LibraryType > &&other)=default
Bdd< LibraryType > restrict(Bdd< LibraryType > const &constraint) const
Computes the restriction of the current BDD with the given constraint.
Definition Bdd.cpp:215
Bdd< LibraryType > implies(Bdd< LibraryType > const &other) const
Performs a logical implication of the current and the given BDD.
Definition Bdd.cpp:162
Bdd(Bdd< LibraryType > const &other)=default
Bdd< LibraryType > renameVariablesConcretize(std::set< storm::expressions::Variable > const &from, std::set< storm::expressions::Variable > const &to) const
Renames the given meta variables in the BDD.
Definition Bdd.cpp:422
InternalBdd< LibraryType > const & getInternalBdd() const
Retrieves the internal BDD.
Definition Bdd.cpp:576
std::vector< ValueType > filterExplicitVector(Odd const &odd, std::vector< ValueType > const &values) const
Filters the given explicit vector using the symbolic representation of which values to select.
Definition Bdd.cpp:582
bool operator==(Bdd< LibraryType > const &other) const
Retrieves whether the two BDDs represent the same function.
Definition Bdd.cpp:103
Bdd< LibraryType > operator||(Bdd< LibraryType > const &other) const
Performs a logical or of the current and the given BDD.
Definition Bdd.cpp:128
virtual uint_fast64_t getLeafCount() const override
Retrieves the number of leaves of the DD.
Definition Bdd.cpp:522
This class is responsible for managing a set of typed variables and all expressions using these varia...
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
LabParser.cpp.
Definition cli.cpp:18