/src/solidity/libsmtutil/SMTPortfolio.h
Line | Count | Source |
1 | | /* |
2 | | This file is part of solidity. |
3 | | |
4 | | solidity is free software: you can redistribute it and/or modify |
5 | | it under the terms of the GNU General Public License as published by |
6 | | the Free Software Foundation, either version 3 of the License, or |
7 | | (at your option) any later version. |
8 | | |
9 | | solidity is distributed in the hope that it will be useful, |
10 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | GNU General Public License for more details. |
13 | | |
14 | | You should have received a copy of the GNU General Public License |
15 | | along with solidity. If not, see <http://www.gnu.org/licenses/>. |
16 | | */ |
17 | | // SPDX-License-Identifier: GPL-3.0 |
18 | | |
19 | | #pragma once |
20 | | |
21 | | |
22 | | #include <libsmtutil/BMCSolverInterface.h> |
23 | | |
24 | | #include <vector> |
25 | | |
26 | | namespace solidity::smtutil |
27 | | { |
28 | | |
29 | | /** |
30 | | * The SMTPortfolio wraps all available solvers within a single interface, |
31 | | * propagating the functionalities to all solvers. |
32 | | * It also checks whether different solvers give conflicting answers |
33 | | * to SMT queries. |
34 | | */ |
35 | | class SMTPortfolio: public BMCSolverInterface |
36 | | { |
37 | | public: |
38 | | /// Noncopyable. |
39 | | SMTPortfolio(SMTPortfolio const&) = delete; |
40 | | SMTPortfolio& operator=(SMTPortfolio const&) = delete; |
41 | | |
42 | | SMTPortfolio(std::vector<std::unique_ptr<BMCSolverInterface>> solvers, std::optional<unsigned> _queryTimeout); |
43 | | |
44 | | void reset() override; |
45 | | |
46 | | void push() override; |
47 | | void pop() override; |
48 | | |
49 | | void declareVariable(std::string const&, SortPointer const&) override; |
50 | | |
51 | | void addAssertion(Expression const& _expr) override; |
52 | | |
53 | | std::pair<CheckResult, std::vector<std::string>> check(std::vector<Expression> const& _expressionsToEvaluate) override; |
54 | | |
55 | | std::vector<std::string> unhandledQueries() override; |
56 | 2.57k | size_t solvers() override { return m_solvers.size(); } |
57 | | |
58 | | std::string dumpQuery(std::vector<Expression> const& _expressionsToEvaluate); |
59 | | |
60 | | private: |
61 | | static bool solverAnswered(CheckResult result); |
62 | | |
63 | | std::vector<std::unique_ptr<BMCSolverInterface>> m_solvers; |
64 | | |
65 | | std::vector<Expression> m_assertions; |
66 | | }; |
67 | | |
68 | | } |