1#ifndef STORM_STORAGE_EXPRESSIONS_EXPRESSIONMANAGER_H_
2#define STORM_STORAGE_EXPRESSIONS_EXPRESSIONMANAGER_H_
7#include <unordered_map>
8#include <unordered_set>
11#include <boost/optional.hpp>
19namespace expressions {
21class ExpressionManager;
27 using value_type = std::pair<storm::expressions::Variable, storm::expressions::Type>
const;
29 using pointer = std::pair<storm::expressions::Variable, storm::expressions::Type>
const*;
30 using reference = std::pair<storm::expressions::Variable, storm::expressions::Type>
const&;
35 std::unordered_map<std::string, uint_fast64_t>::const_iterator nameIndexIteratorEnd,
VariableSelection const& selection);
51 void moveUntilNextSelectedElement(
bool atLeastOneStep =
true);
57 std::unordered_map<std::string, uint_fast64_t>::const_iterator nameIndexIterator;
60 std::unordered_map<std::string, uint_fast64_t>::const_iterator nameIndexIteratorEnd;
66 std::pair<storm::expressions::Variable, storm::expressions::Type> currentElement;
88 std::shared_ptr<ExpressionManager>
clone()
const;
374 uint_fast64_t
getOffset(uint_fast64_t index)
const;
419 static bool isValidVariableName(std::string
const& name);
427 bool variableExists(std::string
const& name)
const;
458 std::set<Variable> variableSet;
461 std::unordered_map<std::string, uint_fast64_t> nameToIndexMapping;
464 std::unordered_map<uint64_t, std::string> indexToNameMapping;
467 std::unordered_map<uint64_t, Type> indexToTypeMapping;
470 uint_fast64_t numberOfBooleanVariables;
471 uint_fast64_t numberOfIntegerVariables;
472 uint_fast64_t numberOfBitVectorVariables;
473 uint_fast64_t numberOfRationalVariables;
474 uint_fast64_t numberOfArrayVariables;
477 uint_fast64_t numberOfAuxiliaryVariables;
480 uint_fast64_t numberOfAuxiliaryBooleanVariables;
481 uint_fast64_t numberOfAuxiliaryIntegerVariables;
482 uint_fast64_t numberOfAuxiliaryBitVectorVariables;
483 uint_fast64_t numberOfAuxiliaryRationalVariables;
484 uint_fast64_t numberOfAuxiliaryArrayVariables;
487 uint_fast64_t freshVariableCounter;
490 mutable boost::optional<Type> booleanType;
491 mutable boost::optional<Type> integerType;
492 mutable std::unordered_set<Type> bitvectorTypes;
493 mutable boost::optional<Type> rationalType;
494 mutable std::unordered_set<Type> arrayTypes;
495 mutable boost::optional<Type> transcendentalNumberType;
498 static const uint64_t auxiliaryMask = (1ull << 50);
501 static const uint64_t offsetMask = (1ull << 50) - 1;
This class is responsible for managing a set of typed variables and all expressions using these varia...
Variable declareFreshIntegerVariable(bool auxiliary=false, std::string const &prefix="_x")
Declares a variable with integer type whose name is guaranteed to be unique and not yet in use.
Type const & getTranscendentalNumberType() const
Retrieves the transcendental numbers type (i.e.
Type const & getBitVectorType(std::size_t width) const
Retrieves the bit vector type of the given width.
std::set< Variable > const & getVariables() const
Retrieves the set of all variables known to this manager.
Type const & getArrayType(Type elementType) const
Retrieves the array type with the given element type.
uint_fast64_t getNumberOfIntegerVariables() const
Retrieves the number of integer variables.
uint_fast64_t getNumberOfBooleanVariables() const
Retrieves the number of boolean variables.
Variable declareFreshBooleanVariable(bool auxiliary=false, std::string const &prefix="_x")
Declares a variable with Boolean type whose name is guaranteed to be unique and not yet in use.
Variable declareRationalVariable(std::string const &name, bool auxiliary=false)
Declares a new rational variable with a name that must not yet exist and its corresponding type.
uint_fast64_t getNumberOfArrayVariables() const
Retrieves the number of array variables.
Variable declareBooleanVariable(std::string const &name, bool auxiliary=false)
Declares a new boolean variable with a name that must not yet exist and its corresponding type.
Expression integer(int_fast64_t value) const
Creates an expression that characterizes the given integer literal.
friend std::ostream & operator<<(std::ostream &out, ExpressionManager const &manager)
Type const & getVariableType(uint_fast64_t index) const
Retrieves the type of the variable with the given index.
bool hasVariable(std::string const &name) const
Retrieves whether a variable with the given name is known to the manager.
Variable declareOrGetVariable(std::string const &name, storm::expressions::Type const &variableType, bool auxiliary=false)
Declares a variable with the given name if it does not yet exist.
ExpressionManager(ExpressionManager &&other)=default
std::shared_ptr< ExpressionManager > clone() const
Creates a new expression manager with the same set of variables.
Type const & getBooleanType() const
Retrieves the boolean type.
const_iterator end() const
Retrieves an iterator that points beyond the last variable managed by this manager.
uint_fast64_t getOffset(uint_fast64_t index) const
Retrieves the offset of the variable with the given index within the group of equally typed variables...
const_iterator begin() const
Retrieves an iterator to all variables managed by this manager.
Variable declareVariable(std::string const &name, storm::expressions::Type const &variableType, bool auxiliary=false)
Declares a variable with a name that must not yet exist and its corresponding type.
ExpressionManager()
Creates a new manager that is unaware of any variables.
Type const & getIntegerType() const
Retrieves the unbounded integer type.
uint_fast64_t getNumberOfVariables() const
Retrieves the number of variables.
Variable declareFreshRationalVariable(bool auxiliary=false, std::string const &prefix="_x")
Declares a variable with rational type whose name is guaranteed to be unique and not yet in use.
Variable declareVariableCopy(Variable const &variable)
Declares a variable that is a copy of the provided variable (i.e.
Variable declareIntegerVariable(std::string const &name, bool auxiliary=false)
Declares a new integer variable with a name that must not yet exist and its corresponding type.
bool operator==(ExpressionManager const &other) const
Compares the two expression managers for equality, which holds iff they are the very same object.
uint_fast64_t getNumberOfRationalVariables() const
Retrieves the number of rational variables.
uint_fast64_t getNumberOfBitVectorVariables() const
Retrieves the number of bit vector variables.
Variable declareArrayVariable(std::string const &name, Type const &elementType, bool auxiliary=false)
Declares a new array variable with the given name and the given element type.
Expression getVariableExpression(std::string const &name) const
Retrieves an expression that represents the variable with the given name.
VariableIterator const_iterator
Expression rational(double value) const
Creates an expression that characterizes the given rational literal.
Variable declareFreshVariable(storm::expressions::Type const &variableType, bool auxiliary=false, std::string const &prefix="_x")
Declares a variable with the given type whose name is guaranteed to be unique and not yet in use.
std::string const & getVariableName(uint_fast64_t index) const
Retrieves the name of the variable with the given index.
std::shared_ptr< ExpressionManager > getSharedPointer()
Retrieves a shared pointer to the expression manager.
Type const & getRationalType() const
Retrieves the rational type.
Variable declareBitVectorVariable(std::string const &name, std::size_t width, bool auxiliary=false)
Declares a new bit vector variable with a name that must not yet exist and the bounded type of the gi...
Variable getVariable(std::string const &name) const
Retrieves the expression that represents the variable with the given name.
Expression boolean(bool value) const
Creates an expression that characterizes the given boolean literal.
ExpressionManager & operator=(ExpressionManager &&other)=default
VariableIterator(VariableIterator &&other)=default
bool operator!=(VariableIterator const &other)
std::pair< storm::expressions::Variable, storm::expressions::Type > const * pointer
std::pair< storm::expressions::Variable, storm::expressions::Type > const & reference
std::input_iterator_tag iterator_category
std::ptrdiff_t difference_type
bool operator==(VariableIterator const &other)
std::pair< storm::expressions::Variable, storm::expressions::Type > const value_type
VariableIterator & operator++()
std::ostream & operator<<(std::ostream &stream, BaseExpression const &expression)