1#ifndef STORM_ADAPTERS_SMT2EXPRESSIONADAPTER_H_
2#define STORM_ADAPTERS_SMT2EXPRESSIONADAPTER_H_
4#include <unordered_map>
6#include "storm-config.h"
28 declaredVariables.emplace_back(std::set<std::string>());
38 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"functionality not (yet) implemented");
51 return "(" + carl::toString(relation) +
" (/ " + leftHandSide.nominator().toString(
false, useReadableVarNames) +
" " +
52 leftHandSide.denominator().toString(
false, useReadableVarNames) +
") (/ " + rightHandSide.nominator().toString(
false, useReadableVarNames) +
53 " " + rightHandSide.denominator().toString(
false, useReadableVarNames) +
") " +
")";
64 ss <<
"(" << relation <<
" " << leftHandSide.toString(
false, useReadableVarNames) <<
" " <<
"0 " <<
")";
75 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"functionality not (yet) implemented");
85 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"functionality not (yet) implemented");
89 for (uint_fast64_t i = 0; i < n; ++i) {
90 declaredVariables.emplace_back(std::set<std::string>());
95 STORM_LOG_THROW(declaredVariables.size() >= n, storm::exceptions::InvalidArgumentException,
"Scope increased too much. Too many calls of pop()?");
96 for (uint_fast64_t i = 0; i < n; ++i) {
97 declaredVariables.pop_back();
105 std::vector<std::string> result;
106 carl::VariablePool& vPool = carl::VariablePool::getInstance();
108 std::string
const& variableString = vPool.getName(variableToCheck, useReadableVarNames);
110 bool alreadyDeclared =
false;
111 for (std::set<std::string>
const& variables : declaredVariables) {
112 if (variables.find(variableString) != variables.end()) {
113 alreadyDeclared =
true;
118 if (!alreadyDeclared) {
120 declaredVariables.back().insert(variableString);
121 std::string varDeclaration =
"( declare-fun " + variableString +
" () ";
122 switch (variableToCheck.type()) {
123 case carl::VariableType::VT_BOOL:
124 varDeclaration +=
"Bool";
126 case carl::VariableType::VT_REAL:
127 varDeclaration +=
"Real";
129 case carl::VariableType::VT_INT:
130 varDeclaration +=
"Int";
133 STORM_LOG_THROW(
false, storm::exceptions::InvalidTypeException,
"The type of the variable is not supported");
135 varDeclaration +=
" )";
136 result.push_back(varDeclaration);
146 bool useReadableVarNames;
148 std::vector<std::set<std::string>> declaredVariables;
std::string translateExpression(storm::expressions::Expression const &)
Translates the given expression to an equivalent expression for Smt2.
std::vector< std::string > const checkForUndeclaredVariables(std::set< storm::RationalFunctionVariable > const &variables)
Checks whether the variables in the given set are already declared and creates them if necessary.
std::string translateExpression(storm::expressions::Variable const &)
Translates the given variable to an equivalent expression for Smt2.
void decreaseScope(uint_fast64_t n=1)
std::string translateExpression(storm::RationalFunction const &leftHandSide, storm::CompareRelation const &relation)
Translates the given constraint "leftHandSide relation 0" to an equivalent expression for Smt2.
std::string translateExpression(storm::RationalFunction const &leftHandSide, storm::CompareRelation const &relation, storm::RationalFunction const &rightHandSide)
Translates the given constraint "leftHandSide relation rightHandSide" to an equivalent expression for...
void increaseScope(uint_fast64_t n=1)
Smt2ExpressionAdapter(storm::expressions::ExpressionManager &, bool useReadableVarNames)
Creates an expression adapter that can translate expressions to the format of Smt2.
storm::expressions::Variable const & getVariable(std::string const &)
Finds the counterpart to the given smt2 variable declaration.
This class is responsible for managing a set of typed variables and all expressions using these varia...
#define STORM_LOG_DEBUG(message)
#define STORM_LOG_THROW(cond, exception, message)
carl::Relation CompareRelation
carl::Variable RationalFunctionVariable