aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/formal/SMTLib2Interface.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-08-02 19:04:58 +0800
committerGitHub <noreply@github.com>2018-08-02 19:04:58 +0800
commit6003ed2abdea76e809b1e6501b9e5a85b38e5859 (patch)
treeddef58c0184de1f80a6e5e9a791a6099f15dd98d /libsolidity/formal/SMTLib2Interface.cpp
parent9ec3fd1632e34abf6aca9d6d3bd0ac0fcfa34f62 (diff)
parent41ac3d6cfb7fedd054f8fbdedf5246ec15670941 (diff)
downloaddexon-solidity-6003ed2abdea76e809b1e6501b9e5a85b38e5859.tar
dexon-solidity-6003ed2abdea76e809b1e6501b9e5a85b38e5859.tar.gz
dexon-solidity-6003ed2abdea76e809b1e6501b9e5a85b38e5859.tar.bz2
dexon-solidity-6003ed2abdea76e809b1e6501b9e5a85b38e5859.tar.lz
dexon-solidity-6003ed2abdea76e809b1e6501b9e5a85b38e5859.tar.xz
dexon-solidity-6003ed2abdea76e809b1e6501b9e5a85b38e5859.tar.zst
dexon-solidity-6003ed2abdea76e809b1e6501b9e5a85b38e5859.zip
Merge pull request #4603 from ethereum/smtlib2
[SMTLib2] Fix repeated declarations
Diffstat (limited to 'libsolidity/formal/SMTLib2Interface.cpp')
-rw-r--r--libsolidity/formal/SMTLib2Interface.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/libsolidity/formal/SMTLib2Interface.cpp b/libsolidity/formal/SMTLib2Interface.cpp
index 8cac3cc6..a6c1f87c 100644
--- a/libsolidity/formal/SMTLib2Interface.cpp
+++ b/libsolidity/formal/SMTLib2Interface.cpp
@@ -47,6 +47,8 @@ void SMTLib2Interface::reset()
{
m_accumulatedOutput.clear();
m_accumulatedOutput.emplace_back();
+ m_constants.clear();
+ m_functions.clear();
write("(set-option :produce-models true)");
write("(set-logic QF_UFLIA)");
}
@@ -64,25 +66,38 @@ void SMTLib2Interface::pop()
void SMTLib2Interface::declareFunction(string _name, Sort _domain, Sort _codomain)
{
- write(
- "(declare-fun |" +
- _name +
- "| (" +
- (_domain == Sort::Int ? "Int" : "Bool") +
- ") " +
- (_codomain == Sort::Int ? "Int" : "Bool") +
- ")"
- );
+ // TODO Use domain and codomain as key as well
+ if (!m_functions.count(_name))
+ {
+ m_functions.insert(_name);
+ write(
+ "(declare-fun |" +
+ _name +
+ "| (" +
+ (_domain == Sort::Int ? "Int" : "Bool") +
+ ") " +
+ (_codomain == Sort::Int ? "Int" : "Bool") +
+ ")"
+ );
+ }
}
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)
{
- 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)