solidity/libsolidity/formal/SMTLib2Interface.h

74 lines
2.0 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-11 11:26:43 +00:00
#include <libsolidity/formal/SMTSolverCommunicator.h>
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-07-11 11:26:43 +00:00
SMTLib2Interface(ReadFile::Callback const& _readFileCallback);
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
2017-07-13 16:22:51 +00:00
Expression newFunction(std::string _name, Sort _domain, Sort _codomain) override;
Expression newInteger(std::string _name) override;
Expression newBool(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-11 11:26:43 +00:00
SMTSolverCommunicator m_communicator;
2017-07-10 19:21:11 +00:00
std::vector<std::string> m_accumulatedOutput;
2017-07-10 16:13:38 +00:00
};
}
}
}