mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[SMTLib2] Fix repeated declarations
This commit is contained in:
parent
e56a88be37
commit
f249f9c86f
@ -47,6 +47,8 @@ void SMTLib2Interface::reset()
|
|||||||
{
|
{
|
||||||
m_accumulatedOutput.clear();
|
m_accumulatedOutput.clear();
|
||||||
m_accumulatedOutput.emplace_back();
|
m_accumulatedOutput.emplace_back();
|
||||||
|
m_constants.clear();
|
||||||
|
m_functions.clear();
|
||||||
write("(set-option :produce-models true)");
|
write("(set-option :produce-models true)");
|
||||||
write("(set-logic QF_UFLIA)");
|
write("(set-logic QF_UFLIA)");
|
||||||
}
|
}
|
||||||
@ -64,25 +66,38 @@ void SMTLib2Interface::pop()
|
|||||||
|
|
||||||
void SMTLib2Interface::declareFunction(string _name, Sort _domain, Sort _codomain)
|
void SMTLib2Interface::declareFunction(string _name, Sort _domain, Sort _codomain)
|
||||||
{
|
{
|
||||||
write(
|
// TODO Use domain and codomain as key as well
|
||||||
"(declare-fun |" +
|
if (!m_functions.count(_name))
|
||||||
_name +
|
{
|
||||||
"| (" +
|
m_functions.insert(_name);
|
||||||
(_domain == Sort::Int ? "Int" : "Bool") +
|
write(
|
||||||
") " +
|
"(declare-fun |" +
|
||||||
(_codomain == Sort::Int ? "Int" : "Bool") +
|
_name +
|
||||||
")"
|
"| (" +
|
||||||
);
|
(_domain == Sort::Int ? "Int" : "Bool") +
|
||||||
|
") " +
|
||||||
|
(_codomain == Sort::Int ? "Int" : "Bool") +
|
||||||
|
")"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMTLib2Interface::declareInteger(string _name)
|
void SMTLib2Interface::declareInteger(string _name)
|
||||||
{
|
{
|
||||||
write("(declare-const |" + _name + "| Int)");
|
if (!m_constants.count(_name))
|
||||||
|
{
|
||||||
|
m_constants.insert(_name);
|
||||||
|
write("(declare-const |" + _name + "| Int)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMTLib2Interface::declareBool(string _name)
|
void SMTLib2Interface::declareBool(string _name)
|
||||||
{
|
{
|
||||||
write("(declare-const |" + _name + "| Bool)");
|
if (!m_constants.count(_name))
|
||||||
|
{
|
||||||
|
m_constants.insert(_name);
|
||||||
|
write("(declare-const |" + _name + "| Bool)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMTLib2Interface::addAssertion(Expression const& _expr)
|
void SMTLib2Interface::addAssertion(Expression const& _expr)
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
namespace dev
|
namespace dev
|
||||||
{
|
{
|
||||||
@ -68,6 +69,8 @@ private:
|
|||||||
|
|
||||||
ReadCallback::Callback m_queryCallback;
|
ReadCallback::Callback m_queryCallback;
|
||||||
std::vector<std::string> m_accumulatedOutput;
|
std::vector<std::string> m_accumulatedOutput;
|
||||||
|
std::set<std::string> m_constants;
|
||||||
|
std::set<std::string> m_functions;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user