dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
Driver.h
1
7#pragma once
8
9#include <iosfwd>
10#include <string>
11
12#include "dlinear/solver/Context.h"
13#include "dlinear/solver/Logic.h"
14#include "dlinear/symbolic/symbolic.h"
15#include "dlinear/util/Stats.h"
16#include "dlinear/util/Timer.h"
17
18namespace dlinear {
19
26class Driver {
27 public:
29 explicit Driver(Context &context, const std::string &class_name = "Driver");
30 virtual ~Driver() = default;
31
39 bool ParseStream(std::istream &in, const std::string &sname = "stream input");
40
48 bool ParseString(const std::string &input, const std::string &sname = "string stream");
49
58 virtual bool ParseFile(const std::string &filename);
59
61 static void Error(const std::string &m);
62
69 void Push(int n) { context_.Push(n); }
76 void Pop(int n) { context_.Pop(n); }
77
78 void Assert(const Formula &f) { context_.Assert(f); }
79
81 void CheckSat();
82
84 void GetModel();
85
90 void GetAssertions() const;
91
96 void GetOption(const std::string &key) const;
97
102 void GetInfo(const std::string &key) const;
108 void SetInfo(const std::string &key, const std::string &value) { context_.SetInfo(key, value); }
114 void SetOption(const std::string &key, const std::string &value) { context_.SetOption(key, value); }
119 void SetLogic(const Logic logic) { context_.SetLogic(logic); }
120
126 void Maximize(const Expression &f);
127
133 void Minimize(const Expression &f);
134
136 void Exit() { context_.Exit(); }
137
139 [[nodiscard]] bool trace_scanning() const { return debug_scanning_; }
141 [[nodiscard]] bool trace_parsing() const { return debug_parsing_; }
143 [[nodiscard]] const Context &context() const { return context_; }
145 [[nodiscard]] const std::string &stream_name() const { return stream_name_; }
147 std::string &m_stream_name() { return stream_name_; }
148
153 [[nodiscard]] const Stats &stats() const { return stats_; }
154
155 protected:
162 virtual bool ParseStreamCore(std::istream &in) = 0;
163
164 std::string stream_name_;
165
167
168 bool debug_scanning_{false};
169
170 bool debug_parsing_{false};
171
174};
175
176} // namespace dlinear
Context class that holds the set of constraints and provide Assert/Push/Pop/CheckSat functionalities.
Definition Context.h:31
void Push(int n)
Push n stacks.
Definition Context.cpp:51
void SetInfo(const std::string &key, const std::string &val)
Set an info key with a value val.
Definition Context.cpp:57
void Assert(const Formula &f)
Assert a formula f.
Definition Context.cpp:24
void SetLogic(Logic logic)
Set the current logic to logic.
Definition Context.cpp:62
void SetOption(const std::string &key, const std::string &val)
Set an option key with a value val.
Definition Context.cpp:63
void Pop(int n)
Pop n stacks.
Definition Context.cpp:46
void Exit()
Exit the context.
Definition Context.cpp:42
The Driver is the base class for all the parsers.
Definition Driver.h:26
std::string & m_stream_name()
Get read-write access to the stream name of the input being parsed.
Definition Driver.h:147
const Stats & stats() const
Statistics for the driver.
Definition Driver.h:153
bool debug_scanning_
Enable debug output in the flex scanner.
Definition Driver.h:168
void CheckSat()
Call context_.CheckSat() and print proper output messages to the standard output.
Definition Driver.cpp:62
void Exit()
Callback for the command exit.
Definition Driver.h:136
Timer * timer_
Pointer to the timer for the driver. Used to Pause the timer when checking sat.
Definition Driver.h:173
const Context & context() const
Get read-only access to the enabled of the Driver.
Definition Driver.h:143
void GetInfo(const std::string &key) const
Callback for the command get-info.
Definition Driver.cpp:93
bool debug_parsing_
Enable debug output in the bison parser.
Definition Driver.h:170
void SetLogic(const Logic logic)
Callback for the command set-logic.
Definition Driver.h:119
bool trace_scanning() const
Check whether the scanner debugger is enabled.
Definition Driver.h:139
bool ParseString(const std::string &input, const std::string &sname="string stream")
Invoke the scanner and parser on an input string.
Definition Driver.cpp:49
void SetOption(const std::string &key, const std::string &value)
Callback for the command set-option.
Definition Driver.h:114
static void Error(const std::string &m)
General error handling.
Definition Driver.cpp:60
Context & context_
The context filled during parsing of the expressions.
Definition Driver.h:166
void Push(int n)
Push the current context to the stack.
Definition Driver.h:69
bool trace_parsing() const
Check whether the trace debugger is enabled.
Definition Driver.h:141
void GetModel()
Return a model computed by the solver in response to an invocation of the check-sat.
Definition Driver.cpp:71
Stats stats_
Statistics for the driver.
Definition Driver.h:172
void SetInfo(const std::string &key, const std::string &value)
Callback for the command set-info.
Definition Driver.h:108
void Minimize(const Expression &f)
Minimize the objective function f.
Definition Driver.cpp:106
Driver(Context &context, const std::string &class_name="Driver")
construct a new parser driver context
Definition Driver.cpp:23
virtual bool ParseFile(const std::string &filename)
Invoke the scanner and parser on a file.
Definition Driver.cpp:54
void GetAssertions() const
Callback for the command get-assertions.
Definition Driver.cpp:76
void GetOption(const std::string &key) const
Callback for the command get-option.
Definition Driver.cpp:88
void Maximize(const Expression &f)
Maximize the objective function f.
Definition Driver.cpp:98
std::string stream_name_
The name of the stream being parsed.
Definition Driver.h:164
const std::string & stream_name() const
Get read-only access to the stream name of the input being parsed.
Definition Driver.h:145
virtual bool ParseStreamCore(std::istream &in)=0
Parse the stream.
bool ParseStream(std::istream &in, const std::string &sname="stream input")
Invoke the scanner and parser for a stream.
Definition Driver.cpp:30
void Pop(int n)
Restore a previously pushed context from the stack.
Definition Driver.h:76
Dataclass collecting statistics about some operation or process.
Definition Stats.h:23
Timer class using the a steady clock.
Definition Timer.h:95
Represents a symbolic form of an expression.
Represents a symbolic form of a first-order logic formula.
Global namespace for the dlinear library.
Logic
The SMT-LIB logic the SMT2 file is using.
Definition Logic.h:17