From 06dbcb3afea63a935afc492b926f6b434bb78fa4 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Fri, 27 Jul 2018 14:13:22 +0200 Subject: Only ask for a model if it's SAT --- libsolidity/formal/Z3Interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libsolidity/formal/Z3Interface.cpp') diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp index 41943c92..7e0788b3 100644 --- a/libsolidity/formal/Z3Interface.cpp +++ b/libsolidity/formal/Z3Interface.cpp @@ -92,7 +92,7 @@ pair> Z3Interface::check(vector const& _ solAssert(false, ""); } - if (result != CheckResult::UNSATISFIABLE && !_expressionsToEvaluate.empty()) + if (result == CheckResult::SATISFIABLE && !_expressionsToEvaluate.empty()) { z3::model m = m_solver.get_model(); for (Expression const& e: _expressionsToEvaluate) -- cgit v1.2.3 From b356f6a7f9e4fcdfa0f7df2e938ad735d231e599 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Fri, 27 Jul 2018 09:14:50 +0200 Subject: Setting timeout to Z3 and CVC4 --- libsolidity/formal/Z3Interface.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libsolidity/formal/Z3Interface.cpp') diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp index 7e0788b3..b57bcb94 100644 --- a/libsolidity/formal/Z3Interface.cpp +++ b/libsolidity/formal/Z3Interface.cpp @@ -28,7 +28,10 @@ using namespace dev::solidity::smt; Z3Interface::Z3Interface(): m_solver(m_context) { + // This needs to be set globally. z3::set_param("rewriter.pull_cheap_ite", true); + // This needs to be set in the context. + m_context.set("timeout", queryTimeout); } void Z3Interface::reset() -- cgit v1.2.3 From 87a38e1abe61547e66aedfa595a73fb78184d609 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Fri, 20 Apr 2018 16:56:10 +0200 Subject: [SMTChecker] SMTPortfolio: use all SMT solvers available --- libsolidity/formal/Z3Interface.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'libsolidity/formal/Z3Interface.cpp') diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp index b57bcb94..784fbd28 100644 --- a/libsolidity/formal/Z3Interface.cpp +++ b/libsolidity/formal/Z3Interface.cpp @@ -51,22 +51,19 @@ void Z3Interface::pop() m_solver.pop(); } -Expression Z3Interface::newFunction(string _name, Sort _domain, Sort _codomain) +void Z3Interface::declareFunction(string _name, Sort _domain, Sort _codomain) { m_functions.insert({_name, m_context.function(_name.c_str(), z3Sort(_domain), z3Sort(_codomain))}); - return SolverInterface::newFunction(move(_name), _domain, _codomain); } -Expression Z3Interface::newInteger(string _name) +void Z3Interface::declareInteger(string _name) { m_constants.insert({_name, m_context.int_const(_name.c_str())}); - return SolverInterface::newInteger(move(_name)); } -Expression Z3Interface::newBool(string _name) +void Z3Interface::declareBool(string _name) { m_constants.insert({_name, m_context.bool_const(_name.c_str())}); - return SolverInterface::newBool(std::move(_name)); } void Z3Interface::addAssertion(Expression const& _expr) -- cgit v1.2.3 From 41ac3d6cfb7fedd054f8fbdedf5246ec15670941 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Wed, 1 Aug 2018 11:12:56 +0200 Subject: Remove repeated declarations in Z3 and CVC4 as well --- libsolidity/formal/Z3Interface.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libsolidity/formal/Z3Interface.cpp') diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp index 784fbd28..747c9172 100644 --- a/libsolidity/formal/Z3Interface.cpp +++ b/libsolidity/formal/Z3Interface.cpp @@ -53,17 +53,20 @@ void Z3Interface::pop() void Z3Interface::declareFunction(string _name, Sort _domain, Sort _codomain) { - m_functions.insert({_name, m_context.function(_name.c_str(), z3Sort(_domain), z3Sort(_codomain))}); + if (!m_functions.count(_name)) + m_functions.insert({_name, m_context.function(_name.c_str(), z3Sort(_domain), z3Sort(_codomain))}); } void Z3Interface::declareInteger(string _name) { - m_constants.insert({_name, m_context.int_const(_name.c_str())}); + if (!m_constants.count(_name)) + m_constants.insert({_name, m_context.int_const(_name.c_str())}); } void Z3Interface::declareBool(string _name) { - m_constants.insert({_name, m_context.bool_const(_name.c_str())}); + if (!m_constants.count(_name)) + m_constants.insert({_name, m_context.bool_const(_name.c_str())}); } void Z3Interface::addAssertion(Expression const& _expr) -- cgit v1.2.3 From 3321000f67add785383adb4ec544aad121552751 Mon Sep 17 00:00:00 2001 From: Anurag Dashputre Date: Sun, 30 Sep 2018 12:40:38 +0530 Subject: Removing extra default cases to force compile time error, instead of runtime. --- libsolidity/formal/Z3Interface.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'libsolidity/formal/Z3Interface.cpp') diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp index 747c9172..9a0ccf48 100644 --- a/libsolidity/formal/Z3Interface.cpp +++ b/libsolidity/formal/Z3Interface.cpp @@ -91,8 +91,6 @@ pair> Z3Interface::check(vector const& _ case z3::check_result::unknown: result = CheckResult::UNKNOWN; break; - default: - solAssert(false, ""); } if (result == CheckResult::SATISFIABLE && !_expressionsToEvaluate.empty()) -- cgit v1.2.3