-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathsolver.h
137 lines (106 loc) · 3.5 KB
/
solver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
solver.h
Abstract:
abstract solver interface
Author:
Leonardo (leonardo) 2011-03-19
Notes:
--*/
#ifndef _SOLVER_H_
#define _SOLVER_H_
#include"check_sat_result.h"
#include"progress_callback.h"
#include"params.h"
class solver;
class solver_factory {
public:
virtual ~solver_factory() {}
virtual solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) = 0;
};
/**
\brief Abstract interface for making solvers available in the Z3
API and front-ends such as SMT 2.0 and (legacy) SMT 1.0.
It provides the basic functionality for incremental solvers.
- assertions
- push/pop
- parameter setting (updt_params)
- statistics
- results based on check_sat_result API
- interruption (set_cancel)
*/
class solver : public check_sat_result {
public:
virtual ~solver() {}
/**
\brief Update the solver internal settings.
*/
virtual void updt_params(params_ref const & p) {}
/**
\brief Store in \c r a description of the configuration
parameters available in this solver.
*/
virtual void collect_param_descrs(param_descrs & r) {}
/**
\brief Enable/Disable model generation for this solver object.
It is invoked before init(m, logic).
The user may optionally invoke it after init(m, logic).
*/
virtual void set_produce_models(bool f) {}
/**
\brief Add a new formula to the assertion stack.
*/
virtual void assert_expr(expr * t) = 0;
/**
\brief Add a new formula \c t to the assertion stack, and "tag" it with \c a.
The propositional varialbe \c a is used to track the use of \c t in a proof
of unsatisfiability.
*/
virtual void assert_expr(expr * t, expr * a) = 0;
/**
\brief Create a backtracking point.
*/
virtual void push() = 0;
/**
\brief Remove \c n backtracking points. All assertions between the pop and matching push are removed.
*/
virtual void pop(unsigned n) = 0;
/**
\brief Return the number of backtracking points.
*/
virtual unsigned get_scope_level() const = 0;
/**
\brief Check if the set of assertions in the assertion stack is satisfiable modulo the given assumptions.
If it is unsatisfiable, and unsat-core generation is enabled. Then, the unsat-core is a subset of these assumptions.
*/
virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions) = 0;
/**
\brief Interrupt this solver.
*/
void cancel() { set_cancel(true); }
/**
\brief Reset the interruption.
*/
void reset_cancel() { set_cancel(false); }
/**
\brief Set a progress callback procedure that is invoked by this solver during check_sat.
This is essentially for backward compatibility and integration with VCC tools.
*/
virtual void set_progress_callback(progress_callback * callback) = 0;
/**
\brief Return the number of assertions in the assertion stack.
*/
virtual unsigned get_num_assertions() const;
/**
\brief Return the assertion at position idx in the assertion stack.
*/
virtual expr * get_assertion(unsigned idx) const;
/**
\brief Display the content of this solver.
*/
virtual void display(std::ostream & out) const;
protected:
virtual void set_cancel(bool f) = 0;
};
#endif