P4C
The P4 Compiler
Loading...
Searching...
No Matches
solver.h
1#ifndef IR_SOLVER_H_
2#define IR_SOLVER_H_
3
4#include <optional>
5#include <vector>
6
7#include <boost/container/flat_map.hpp>
8#include <boost/container/flat_set.hpp>
9
10#include "ir/ir.h"
11#include "lib/castable.h"
12#include "lib/cstring.h"
13
15// TODO: This should implement AbstractRepCheckedNode<Constraint>.
16using Constraint = IR::Expression;
17
20 bool operator()(const IR::SymbolicVariable *s1, const IR::SymbolicVariable *s2) const {
21 return s1->operator<(*s2);
22 }
23};
24
26using SymbolicMapping = boost::container::flat_map<const IR::SymbolicVariable *,
27 const IR::Expression *, SymbolicVarComp>;
28
29using SymbolicSet = boost::container::flat_set<const IR::SymbolicVariable *, SymbolicVarComp>;
30
32class AbstractSolver : public ICastable {
33 public:
36 virtual void comment(cstring comment) = 0;
37
40 virtual void seed(unsigned seed) = 0;
41
43 virtual void timeout(unsigned tm) = 0;
44
50 virtual std::optional<bool> checkSat(const std::vector<const Constraint *> &asserts) = 0;
51
58 [[nodiscard]] virtual const SymbolicMapping &getSymbolicMapping() const = 0;
59
61 virtual void toJSON(JSONGenerator &) const = 0;
62
64 [[nodiscard]] virtual bool isInIncrementalMode() const = 0;
65
66 DECLARE_TYPEINFO(AbstractSolver);
67};
68
69#endif /* IR_SOLVER_H_ */
Provides a higher-level interface for an SMT solver.
Definition solver.h:32
virtual void comment(cstring comment)=0
virtual bool isInIncrementalMode() const =0
virtual void seed(unsigned seed)=0
virtual std::optional< bool > checkSat(const std::vector< const Constraint * > &asserts)=0
virtual const SymbolicMapping & getSymbolicMapping() const =0
virtual void toJSON(JSONGenerator &) const =0
Saves solver state to the given JSON generator.
virtual void timeout(unsigned tm)=0
Sets timeout for solver in milliseconds.
Definition castable.h:34
Definition json_generator.h:34
Definition cstring.h:80
Comparator to compare SymbolicVariable pointers.
Definition solver.h:19