/* 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 . */ // SPDX-License-Identifier: GPL-3.0 /** * Interface for solving Horn systems via smtlib2. */ #pragma once #include #include namespace solidity::smtutil { class CHCSmtLib2Interface: public CHCSolverInterface { public: explicit CHCSmtLib2Interface( std::map const& _queryResponses, frontend::ReadCallback::Callback const& _smtCallback ); void reset(); void registerRelation(Expression const& _expr) override; void addRule(Expression const& _expr, std::string const& _name) override; std::pair> query(Expression const& _expr) override; void declareVariable(std::string const& _name, SortPointer const& _sort) override; std::vector unhandledQueries() const { return m_unhandledQueries; } SMTLib2Interface* smtlib2Interface() const { return m_smtlib2.get(); } private: void declareFunction(std::string const& _name, SortPointer const& _sort); void write(std::string _data); /// Communicates with the solver via the callback. Throws SMTSolverError on error. std::string querySolver(std::string const& _input); /// Used to access toSmtLibSort, SExpr, and handle variables. std::unique_ptr m_smtlib2; std::string m_accumulatedOutput; std::set m_variables; std::map const& m_queryResponses; std::vector m_unhandledQueries; frontend::ReadCallback::Callback m_smtCallback; }; }