Browse Source
Added support for cloning IR expressions.
Added support for cloning IR expressions.
Former-commit-id: 913269b3a5
tempestpy_adaptions
dehnert
11 years ago
31 changed files with 151 additions and 186 deletions
-
2src/adapters/Z3ExpressionAdapter.h
-
18src/counterexamples/SMTMinimalCommandSetGenerator.h
-
9src/ir/expressions/BaseExpression.h
-
4src/ir/expressions/BinaryBooleanFunctionExpression.cpp
-
2src/ir/expressions/BinaryBooleanFunctionExpression.h
-
4src/ir/expressions/BinaryNumericalFunctionExpression.cpp
-
2src/ir/expressions/BinaryNumericalFunctionExpression.h
-
4src/ir/expressions/BinaryRelationExpression.cpp
-
2src/ir/expressions/BinaryRelationExpression.h
-
4src/ir/expressions/BooleanConstantExpression.cpp
-
2src/ir/expressions/BooleanConstantExpression.h
-
62src/ir/expressions/BooleanLiteral.h
-
4src/ir/expressions/BooleanLiteralExpression.cpp
-
2src/ir/expressions/BooleanLiteralExpression.h
-
4src/ir/expressions/DoubleConstantExpression.cpp
-
2src/ir/expressions/DoubleConstantExpression.h
-
62src/ir/expressions/DoubleLiteral.h
-
4src/ir/expressions/DoubleLiteralExpression.cpp
-
2src/ir/expressions/DoubleLiteralExpression.h
-
4src/ir/expressions/IntegerConstantExpression.cpp
-
2src/ir/expressions/IntegerConstantExpression.h
-
58src/ir/expressions/IntegerLiteral.h
-
4src/ir/expressions/IntegerLiteralExpression.cpp
-
2src/ir/expressions/IntegerLiteralExpression.h
-
4src/ir/expressions/UnaryBooleanFunctionExpression.cpp
-
2src/ir/expressions/UnaryBooleanFunctionExpression.h
-
4src/ir/expressions/UnaryNumericalFunctionExpression.cpp
-
2src/ir/expressions/UnaryNumericalFunctionExpression.h
-
4src/ir/expressions/VariableExpression.cpp
-
2src/ir/expressions/VariableExpression.h
-
54src/utility/IRUtility.h
@ -1,62 +0,0 @@ |
|||
/* |
|||
* BooleanLiteral.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef STORM_IR_EXPRESSIONS_BOOLEANLITERAL_H_ |
|||
#define STORM_IR_EXPRESSIONS_BOOLEANLITERAL_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace ir { |
|||
namespace expressions { |
|||
|
|||
class BooleanLiteral : public BaseExpression { |
|||
public: |
|||
bool value; |
|||
|
|||
BooleanLiteral(bool value) : BaseExpression(bool_), value(value) { |
|||
|
|||
} |
|||
|
|||
virtual ~BooleanLiteral() { |
|||
|
|||
} |
|||
|
|||
virtual std::shared_ptr<BaseExpression> clone(const std::map<std::string, std::string>& renaming, const std::map<std::string, uint_fast64_t>& bools, const std::map<std::string, uint_fast64_t>& ints) override { |
|||
return std::shared_ptr<BaseExpression>(new BooleanLiteral(this->value)); |
|||
} |
|||
|
|||
virtual bool getValueAsBool(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const override { |
|||
return value; |
|||
} |
|||
|
|||
virtual void accept(ExpressionVisitor* visitor) override { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
virtual std::string toString() const override { |
|||
if (value) { |
|||
return std::string("true"); |
|||
} else { |
|||
return std::string("false"); |
|||
} |
|||
} |
|||
|
|||
virtual std::string dump(std::string prefix) const override { |
|||
std::stringstream result; |
|||
result << prefix << "BooleanLiteral " << this->toString() << std::endl; |
|||
return result.str(); |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
#endif /* STORM_IR_EXPRESSIONS_BOOLEANLITERAL_H_ */ |
@ -1,62 +0,0 @@ |
|||
/* |
|||
* DoubleLiteral.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef STORM_IR_EXPRESSIONS_DOUBLELITERAL_H_ |
|||
#define STORM_IR_EXPRESSIONS_DOUBLELITERAL_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
#include "boost/lexical_cast.hpp" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class DoubleLiteral : public BaseExpression { |
|||
public: |
|||
double value; |
|||
|
|||
DoubleLiteral(double value) : BaseExpression(double_), value(value) { |
|||
|
|||
} |
|||
|
|||
virtual ~DoubleLiteral() { |
|||
|
|||
} |
|||
|
|||
virtual std::shared_ptr<BaseExpression> clone(const std::map<std::string, std::string>& renaming, const std::map<std::string, uint_fast64_t>& bools, const std::map<std::string, uint_fast64_t>& ints) override { |
|||
return std::shared_ptr<BaseExpression>(new DoubleLiteral(this->value)); |
|||
} |
|||
|
|||
virtual double getValueAsDouble(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const override { |
|||
return value; |
|||
} |
|||
|
|||
virtual void accept(ExpressionVisitor* visitor) override { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
virtual std::string toString() const override { |
|||
return boost::lexical_cast<std::string>(value); |
|||
} |
|||
|
|||
virtual std::string dump(std::string prefix) const override { |
|||
std::stringstream result; |
|||
result << prefix << "DoubleLiteral " << this->toString() << std::endl; |
|||
return result.str(); |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
#endif /* STORM_IR_EXPRESSIONS_DOUBLELITERAL_H_ */ |
@ -1,58 +0,0 @@ |
|||
/* |
|||
* IntegerLiteral.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef STORM_IR_EXPRESSIONS_INTEGERLITERAL_H_ |
|||
#define STORM_IR_EXPRESSIONS_INTEGERLITERAL_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class IntegerLiteral : public BaseExpression { |
|||
public: |
|||
int_fast64_t value; |
|||
|
|||
IntegerLiteral(int_fast64_t value) : BaseExpression(int_), value(value) { |
|||
} |
|||
|
|||
virtual ~IntegerLiteral() { |
|||
} |
|||
|
|||
virtual std::shared_ptr<BaseExpression> clone(const std::map<std::string, std::string>& renaming, const std::map<std::string, uint_fast64_t>& bools, const std::map<std::string, uint_fast64_t>& ints) override { |
|||
return std::shared_ptr<BaseExpression>(new IntegerLiteral(this->value)); |
|||
} |
|||
|
|||
virtual int_fast64_t getValueAsInt(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const override { |
|||
return value; |
|||
} |
|||
|
|||
virtual void accept(ExpressionVisitor* visitor) override { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
virtual std::string toString() const override { |
|||
return boost::lexical_cast<std::string>(value); |
|||
} |
|||
|
|||
virtual std::string dump(std::string prefix) const override { |
|||
std::stringstream result; |
|||
result << prefix << "IntegerLiteral " << this->toString() << std::endl; |
|||
return result.str(); |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
#endif /* STORM_IR_EXPRESSIONS_INTEGERLITERAL_H_ */ |
@ -0,0 +1,54 @@ |
|||
/* |
|||
* IRUtility.h |
|||
* |
|||
* Created on: 05.10.2013 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_UTILITY_IRUTILITY_H_ |
|||
#define STORM_UTILITY_IRUTILITY_H_ |
|||
|
|||
#include <IR.h> |
|||
|
|||
#include "log4cplus/logger.h" |
|||
#include "log4cplus/loggingmacros.h" |
|||
|
|||
extern log4cplus::Logger logger; |
|||
|
|||
namespace storm { |
|||
namespace utility { |
|||
namespace ir { |
|||
|
|||
/*! |
|||
* Computes the weakest precondition of the given boolean expression wrt. the given updates. The weakest |
|||
* precondition is the most liberal expression that must hold in order to satisfy the given boolean |
|||
* expression after performing the updates. The updates must be disjoint in the sense that they must not |
|||
* assign an expression to a variable twice or more. |
|||
* |
|||
* @param expression The expression for which to build the weakest precondition. |
|||
* @param update The update with respect to which to compute the weakest precondition. |
|||
*/ |
|||
std::shared_ptr<storm::ir::expressions::BaseExpression> getWeakestPrecondition(std::shared_ptr<storm::ir::expressions::BaseExpression> booleanExpression, std::vector<storm::ir::Update> const& updates) { |
|||
std::map<std::string, std::shared_ptr<storm::ir::expressions::BaseExpression>> variableToExpressionMap; |
|||
|
|||
// Construct the full substitution we need to perform later. |
|||
for (auto const& update : updates) { |
|||
for (uint_fast64_t assignmentIndex = 0; assignmentIndex < update.getNumberOfAssignments(); ++assignmentIndex) { |
|||
storm::ir::Assignment const& update.getAssignment(assignmentIndex); |
|||
|
|||
variableToExpressionMap[assignment.getVariableName()] = assignment.getExpression(); |
|||
} |
|||
} |
|||
|
|||
// Copy the given expression and apply the substitution. |
|||
std::shared_ptr<storm::ir::expressions::BaseExpression> copiedExpression = booleanExpression->clone(); |
|||
copiedExpression->substitute(variableToExpressionMap); |
|||
|
|||
return copiedExpression; |
|||
} |
|||
|
|||
} // namespace ir |
|||
} // namespace utility |
|||
} // namespace storm |
|||
|
|||
#endif /* STORM_UTILITY_IRUTILITY_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue