Browse Source
added option of splitting to predicate synthesis, added equivalence checker, fixed bug that caused some commands not to be abstracted
tempestpy_adaptions
added option of splitting to predicate synthesis, added equivalence checker, fixed bug that caused some commands not to be abstracted
tempestpy_adaptions
dehnert
8 years ago
15 changed files with 308 additions and 118 deletions
-
17src/storm/abstraction/prism/AbstractCommand.cpp
-
3src/storm/abstraction/prism/AbstractCommand.h
-
79src/storm/abstraction/prism/AbstractProgram.cpp
-
16src/storm/abstraction/prism/AbstractProgram.h
-
8src/storm/abstraction/prism/PrismMenuGameAbstractor.cpp
-
95src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp
-
6src/storm/settings/modules/AbstractionSettings.cpp
-
8src/storm/settings/modules/AbstractionSettings.h
-
23src/storm/storage/expressions/EquivalenceChecker.cpp
-
28src/storm/storage/expressions/EquivalenceChecker.h
-
14src/storm/storage/expressions/Expression.h
-
80src/storm/storage/expressions/PredicateSplitter.cpp
-
31src/storm/storage/expressions/PredicateSplitter.h
-
6src/storm/utility/graph.cpp
-
12src/test/abstraction/PrismMenuGameTest.cpp
@ -0,0 +1,23 @@ |
|||
#include "storm/storage/expressions/EquivalenceChecker.h"
|
|||
|
|||
#include "storm/solver/SmtSolver.h"
|
|||
|
|||
#include "storm/storage/expressions/Expression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
|
|||
EquivalenceChecker::EquivalenceChecker(std::unique_ptr<storm::solver::SmtSolver>&& smtSolver, storm::expressions::Expression const& constraint) : smtSolver(std::move(smtSolver)) { |
|||
this->smtSolver->add(constraint); |
|||
} |
|||
|
|||
bool EquivalenceChecker::areEquivalent(storm::expressions::Expression const& first, storm::expressions::Expression const& second) { |
|||
this->smtSolver->push(); |
|||
this->smtSolver->add((first && !second) || (!first && second)); |
|||
bool equivalent = smtSolver->check() == storm::solver::SmtSolver::CheckResult::Unsat; |
|||
this->smtSolver->pop(); |
|||
return equivalent; |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
#pragma once |
|||
|
|||
#include <memory> |
|||
|
|||
#include "storm/solver/SmtSolver.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class Expression; |
|||
|
|||
class EquivalenceChecker { |
|||
public: |
|||
/*! |
|||
* Creates an equivalence checker with the given solver and constraint. |
|||
* |
|||
* @param smtSolver The solver to use. |
|||
* @param constraint An additional constraint. Must be satisfiable. |
|||
*/ |
|||
EquivalenceChecker(std::unique_ptr<storm::solver::SmtSolver>&& smtSolver, storm::expressions::Expression const& constraint); |
|||
|
|||
bool areEquivalent(storm::expressions::Expression const& first, storm::expressions::Expression const& second); |
|||
|
|||
private: |
|||
std::unique_ptr<storm::solver::SmtSolver> smtSolver; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,80 @@ |
|||
#include "storm/storage/expressions/PredicateSplitter.h"
|
|||
|
|||
#include "storm/storage/expressions/Expression.h"
|
|||
#include "storm/storage/expressions/Expressions.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
#include "storm/exceptions/InvalidArgumentException.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
|
|||
std::vector<storm::expressions::Expression> PredicateSplitter::split(storm::expressions::Expression const& expression) { |
|||
STORM_LOG_THROW(expression.hasBooleanType(), storm::exceptions::InvalidArgumentException, "Expected predicate of boolean type."); |
|||
|
|||
// Gather all atoms.
|
|||
atomicExpressions.clear(); |
|||
expression.accept(*this, boost::none); |
|||
|
|||
// Remove all boolean literals from the atoms.
|
|||
std::vector<storm::expressions::Expression> atomsToKeep; |
|||
for (auto const& atom : atomicExpressions) { |
|||
if (!atom.isTrue() && !atom.isFalse()) { |
|||
atomsToKeep.push_back(atom); |
|||
} |
|||
} |
|||
atomicExpressions = std::move(atomsToKeep); |
|||
|
|||
return atomicExpressions; |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(IfThenElseExpression const& expression, boost::any const&) { |
|||
atomicExpressions.push_back(expression.shared_from_this()); |
|||
return boost::any(); |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(BinaryBooleanFunctionExpression const& expression, boost::any const& data) { |
|||
expression.getFirstOperand()->accept(*this, data); |
|||
expression.getSecondOperand()->accept(*this, data); |
|||
return boost::any(); |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(BinaryNumericalFunctionExpression const&, boost::any const&) { |
|||
return boost::any(); |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(BinaryRelationExpression const& expression, boost::any const&) { |
|||
atomicExpressions.push_back(expression.shared_from_this()); |
|||
return boost::any(); |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(VariableExpression const& expression, boost::any const&) { |
|||
if (expression.hasBooleanType()) { |
|||
atomicExpressions.push_back(expression.shared_from_this()); |
|||
} |
|||
return boost::any(); |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(UnaryBooleanFunctionExpression const& expression, boost::any const& data) { |
|||
expression.getOperand()->accept(*this, data); |
|||
return boost::any(); |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(UnaryNumericalFunctionExpression const&, boost::any const&) { |
|||
return boost::any(); |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(BooleanLiteralExpression const&, boost::any const&) { |
|||
return boost::any(); |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(IntegerLiteralExpression const&, boost::any const&) { |
|||
return boost::any(); |
|||
} |
|||
|
|||
boost::any PredicateSplitter::visit(RationalLiteralExpression const&, boost::any const&) { |
|||
return boost::any(); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
#pragma once |
|||
|
|||
#include <vector> |
|||
|
|||
#include "storm/storage/expressions/ExpressionVisitor.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class Expression; |
|||
|
|||
class PredicateSplitter : public ExpressionVisitor { |
|||
public: |
|||
std::vector<storm::expressions::Expression> split(storm::expressions::Expression const& expression); |
|||
|
|||
virtual boost::any visit(IfThenElseExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(BinaryBooleanFunctionExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(BinaryNumericalFunctionExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(BinaryRelationExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(VariableExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(UnaryBooleanFunctionExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(UnaryNumericalFunctionExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(BooleanLiteralExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(IntegerLiteralExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(RationalLiteralExpression const& expression, boost::any const& data) override; |
|||
|
|||
private: |
|||
std::vector<storm::expressions::Expression> atomicExpressions; |
|||
}; |
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue