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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include <libsolidity/formal/SolverInterface.h>
|
|
|
|
#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>
|
|
|
|
|
2019-12-11 16:31:36 +00:00
|
|
|
namespace solidity::frontend::smt
|
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(
|
2019-12-11 16:31:36 +00:00
|
|
|
std::map<util::h256, std::string> const& _smtlib2Responses,
|
2019-12-05 15:44:26 +00:00
|
|
|
ReadCallback::Callback const& _smtCallback,
|
2019-12-03 13:39:47 +00:00
|
|
|
SMTSolverChoice _enabledSolvers
|
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
|
|
|
|
2019-09-02 12:27:35 +00:00
|
|
|
void addAssertion(smt::Expression const& _expr) override;
|
2019-06-04 12:43:26 +00:00
|
|
|
|
2019-09-02 12:27:35 +00:00
|
|
|
std::pair<CheckResult, std::vector<std::string>> check(std::vector<smt::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;
|
|
|
|
unsigned solvers() override { return m_solvers.size(); }
|
2018-04-20 14:56:10 +00:00
|
|
|
private:
|
|
|
|
static bool solverAnswered(CheckResult result);
|
|
|
|
|
2019-05-09 08:56:58 +00:00
|
|
|
std::vector<std::unique_ptr<smt::SolverInterface>> m_solvers;
|
2019-06-04 12:43:26 +00:00
|
|
|
|
2019-09-02 12:27:35 +00:00
|
|
|
std::vector<smt::Expression> m_assertions;
|
2018-04-20 14:56:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|