aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/formal/SMTLib2Interface.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-11-22 22:20:26 +0800
committerchriseth <chris@ethereum.org>2017-11-22 22:20:26 +0800
commit762d591a4755fbabfe8d2556bab10b77ec1d5bb5 (patch)
treedbb543e2c7a56387938a971b5b1d7550c85bbfb9 /libsolidity/formal/SMTLib2Interface.cpp
parent7fc7fa4293707a6540c3483fcc133e0934e8f229 (diff)
downloaddexon-solidity-762d591a4755fbabfe8d2556bab10b77ec1d5bb5.tar.gz
dexon-solidity-762d591a4755fbabfe8d2556bab10b77ec1d5bb5.tar.zst
dexon-solidity-762d591a4755fbabfe8d2556bab10b77ec1d5bb5.zip
Introduce sorts for smt expressions.
Diffstat (limited to 'libsolidity/formal/SMTLib2Interface.cpp')
-rw-r--r--libsolidity/formal/SMTLib2Interface.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/libsolidity/formal/SMTLib2Interface.cpp b/libsolidity/formal/SMTLib2Interface.cpp
index c627057a..0e00665a 100644
--- a/libsolidity/formal/SMTLib2Interface.cpp
+++ b/libsolidity/formal/SMTLib2Interface.cpp
@@ -64,8 +64,6 @@ void SMTLib2Interface::pop()
Expression SMTLib2Interface::newFunction(string _name, Sort _domain, Sort _codomain)
{
- solAssert(!m_variables.count(_name), "");
- m_variables[_name] = SMTVariableType::Function;
write(
"(declare-fun |" +
_name +
@@ -80,16 +78,12 @@ Expression SMTLib2Interface::newFunction(string _name, Sort _domain, Sort _codom
Expression SMTLib2Interface::newInteger(string _name)
{
- solAssert(!m_variables.count(_name), "");
- m_variables[_name] = SMTVariableType::Integer;
write("(declare-const |" + _name + "| Int)");
return SolverInterface::newInteger(move(_name));
}
Expression SMTLib2Interface::newBool(string _name)
{
- solAssert(!m_variables.count(_name), "");
- m_variables[_name] = SMTVariableType::Bool;
write("(declare-const |" + _name + "| Bool)");
return SolverInterface::newBool(std::move(_name));
}
@@ -151,9 +145,8 @@ string SMTLib2Interface::checkSatAndGetValuesCommand(vector<Expression> const& _
for (size_t i = 0; i < _expressionsToEvaluate.size(); i++)
{
auto const& e = _expressionsToEvaluate.at(i);
- solAssert(m_variables.count(e.name), "");
- solAssert(m_variables[e.name] == SMTVariableType::Integer, "");
- command += "(declare-const |EVALEXPR_" + to_string(i) + "| Int)\n";
+ solAssert(e.sort == Sort::Int || e.sort == Sort::Bool, "Invalid sort for expression to evaluate.");
+ command += "(declare-const |EVALEXPR_" + to_string(i) + "| " + (e.sort == Sort::Int ? "Int" : "Bool") + "\n";
command += "(assert (= |EVALEXPR_" + to_string(i) + "| " + toSExpr(e) + "))\n";
}
command += "(check-sat)\n";