solidity/libsolidity/formal/SMTLib2Interface.h

76 lines
2.1 KiB
C
Raw Normal View History

2017-07-10 16:13:38 +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
2017-07-13 16:22:51 +00:00
#include <libsolidity/formal/SolverInterface.h>
2017-07-11 11:26:43 +00:00
2017-07-10 19:21:11 +00:00
#include <libsolidity/interface/Exceptions.h>
2017-07-11 11:26:43 +00:00
#include <libsolidity/interface/ReadFile.h>
2017-07-10 19:21:11 +00:00
#include <libdevcore/Common.h>
2017-07-11 11:26:43 +00:00
#include <boost/noncopyable.hpp>
2017-07-10 16:13:38 +00:00
#include <map>
#include <string>
#include <vector>
2017-07-10 19:21:11 +00:00
#include <cstdio>
2017-07-10 16:13:38 +00:00
namespace dev
{
namespace solidity
{
namespace smt
{
2017-07-13 16:22:51 +00:00
class SMTLib2Interface: public SolverInterface, public boost::noncopyable
2017-07-10 16:13:38 +00:00
{
public:
2017-08-30 21:43:01 +00:00
explicit SMTLib2Interface(ReadCallback::Callback const& _queryCallback);
2017-07-10 16:13:38 +00:00
2017-07-13 16:22:51 +00:00
void reset() override;
2017-07-10 16:13:38 +00:00
2017-07-13 16:22:51 +00:00
void push() override;
void pop() override;
2017-07-10 16:13:38 +00:00
void declareFunction(std::string _name, Sort _domain, Sort _codomain) override;
void declareInteger(std::string _name) override;
void declareBool(std::string _name) override;
2017-07-10 16:13:38 +00:00
2017-07-13 16:22:51 +00:00
void addAssertion(Expression const& _expr) override;
std::pair<CheckResult, std::vector<std::string>> check(std::vector<Expression> const& _expressionsToEvaluate) override;
2017-07-10 19:21:11 +00:00
private:
2017-07-13 16:22:51 +00:00
std::string toSExpr(Expression const& _expr);
2017-07-10 19:21:11 +00:00
void write(std::string _data);
2017-07-11 11:26:43 +00:00
std::string checkSatAndGetValuesCommand(std::vector<Expression> const& _expressionsToEvaluate);
2017-07-10 19:21:11 +00:00
std::vector<std::string> parseValues(std::string::const_iterator _start, std::string::const_iterator _end);
2017-07-13 19:06:29 +00:00
/// Communicates with the solver via the callback. Throws SMTSolverError on error.
std::string querySolver(std::string const& _input);
ReadCallback::Callback m_queryCallback;
2017-07-10 19:21:11 +00:00
std::vector<std::string> m_accumulatedOutput;
2017-07-10 16:13:38 +00:00
};
}
}
}