2018-04-20 14:56:10 +00:00
|
|
|
/*
|
|
|
|
This file is part of solidity.
|
|
|
|
|
|
|
|
solidity is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
solidity is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-07-17 14:54:12 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0
|
2018-04-20 14:56:10 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
2020-05-18 15:42:24 +00:00
|
|
|
#include <libsmtutil/SolverInterface.h>
|
2018-04-20 14:56:10 +00:00
|
|
|
#include <libsolidity/interface/ReadFile.h>
|
2020-01-06 10:52:23 +00:00
|
|
|
#include <libsolutil/FixedHash.h>
|
2017-10-13 13:19:53 +00:00
|
|
|
|
2018-04-20 14:56:10 +00:00
|
|
|
#include <boost/noncopyable.hpp>
|
2017-10-13 13:19:53 +00:00
|
|
|
#include <map>
|
2018-04-20 14:56:10 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2020-05-19 12:14:46 +00:00
|
|
|
namespace solidity::smtutil
|
2018-04-20 14:56:10 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The SMTPortfolio wraps all available solvers within a single interface,
|
|
|
|
* propagating the functionalities to all solvers.
|
|
|
|
* It also checks whether different solvers give conflicting answers
|
|
|
|
* to SMT queries.
|
|
|
|
*/
|
|
|
|
class SMTPortfolio: public SolverInterface, public boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
2019-09-17 14:06:43 +00:00
|
|
|
SMTPortfolio(
|
2020-05-11 17:56:29 +00:00
|
|
|
std::map<util::h256, std::string> _smtlib2Responses = {},
|
|
|
|
frontend::ReadCallback::Callback _smtCallback = {},
|
2020-11-02 20:20:20 +00:00
|
|
|
SMTSolverChoice _enabledSolvers = SMTSolverChoice::All(),
|
|
|
|
std::optional<unsigned> _queryTimeout = {}
|
2019-09-17 14:06:43 +00:00
|
|
|
);
|
2018-04-20 14:56:10 +00:00
|
|
|
|
|
|
|
void reset() override;
|
|
|
|
|
|
|
|
void push() override;
|
|
|
|
void pop() override;
|
|
|
|
|
2019-09-24 15:35:31 +00:00
|
|
|
void declareVariable(std::string const&, SortPointer const&) override;
|
2018-04-20 14:56:10 +00:00
|
|
|
|
2020-05-19 12:14:46 +00:00
|
|
|
void addAssertion(Expression const& _expr) override;
|
2019-06-04 12:43:26 +00:00
|
|
|
|
2020-05-19 12:14:46 +00:00
|
|
|
std::pair<CheckResult, std::vector<std::string>> check(std::vector<Expression> const& _expressionsToEvaluate) override;
|
2018-04-20 14:56:10 +00:00
|
|
|
|
2019-01-23 10:22:38 +00:00
|
|
|
std::vector<std::string> unhandledQueries() override;
|
2020-07-13 20:40:33 +00:00
|
|
|
size_t solvers() override { return m_solvers.size(); }
|
2018-04-20 14:56:10 +00:00
|
|
|
private:
|
|
|
|
static bool solverAnswered(CheckResult result);
|
|
|
|
|
2020-05-19 12:14:46 +00:00
|
|
|
std::vector<std::unique_ptr<SolverInterface>> m_solvers;
|
2019-06-04 12:43:26 +00:00
|
|
|
|
2020-05-19 12:14:46 +00:00
|
|
|
std::vector<Expression> m_assertions;
|
2018-04-20 14:56:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|