solidity/libsmtutil/SMTPortfolio.h

78 lines
2.2 KiB
C
Raw Permalink Normal View History

/*
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/>.
*/
// SPDX-License-Identifier: GPL-3.0
#pragma once
2020-05-18 15:42:24 +00:00
#include <libsmtutil/SolverInterface.h>
#include <libsolidity/interface/ReadFile.h>
#include <libsolutil/FixedHash.h>
#include <map>
#include <vector>
2020-05-19 12:14:46 +00:00
namespace solidity::smtutil
{
/**
* 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:
/// Noncopyable.
SMTPortfolio(SMTPortfolio const&) = delete;
SMTPortfolio& operator=(SMTPortfolio const&) = delete;
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 = {},
bool _printQuery = false
);
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;
2020-05-19 12:14:46 +00:00
void addAssertion(Expression const& _expr) override;
2020-05-19 12:14:46 +00:00
std::pair<CheckResult, std::vector<std::string>> check(std::vector<Expression> const& _expressionsToEvaluate) override;
std::vector<std::string> unhandledQueries() override;
2020-07-13 20:40:33 +00:00
size_t solvers() override { return m_solvers.size(); }
std::string dumpQuery(std::vector<Expression> const& _expressionsToEvaluate);
private:
static bool solverAnswered(CheckResult result);
2020-05-19 12:14:46 +00:00
std::vector<std::unique_ptr<SolverInterface>> m_solvers;
2020-05-19 12:14:46 +00:00
std::vector<Expression> m_assertions;
};
}