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 "absl/container/btree_map.h"
8#include "ir/compare.h"
9#include "ir/ir.h"
10#include "lib/castable.h"
11#include "lib/cstring.h"
12
13namespace P4 {
14
16// TODO: This should implement AbstractRepCheckedNode<Constraint>.
17using Constraint = IR::Expression;
18
21 absl::btree_map<const IR::SymbolicVariable *, const IR::Expression *, IR::SymbolicVariableLess>;
22
24class AbstractSolver : public ICastable {
25 public:
28 virtual void comment(cstring comment) = 0;
29
32 virtual void seed(unsigned seed) = 0;
33
35 virtual void timeout(unsigned tm) = 0;
36
42 virtual std::optional<bool> checkSat(const std::vector<const Constraint *> &asserts) = 0;
43
50 [[nodiscard]] virtual const SymbolicMapping &getSymbolicMapping() const = 0;
51
53 virtual void toJSON(JSONGenerator &) const = 0;
54
56 [[nodiscard]] virtual bool isInIncrementalMode() const = 0;
57
58 DECLARE_TYPEINFO(AbstractSolver);
59};
60
61} // namespace P4
62
63#endif /* IR_SOLVER_H_ */
Provides a higher-level interface for an SMT solver.
Definition solver.h:24
virtual std::optional< bool > checkSat(const std::vector< const Constraint * > &asserts)=0
virtual void toJSON(JSONGenerator &) const =0
Saves solver state to the given JSON generator.
virtual void comment(cstring comment)=0
virtual void timeout(unsigned tm)=0
Sets timeout for solver in milliseconds.
virtual const SymbolicMapping & getSymbolicMapping() const =0
virtual bool isInIncrementalMode() const =0
virtual void seed(unsigned seed)=0
Definition castable.h:36
Definition json_generator.h:36
Definition cstring.h:85
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
IR::Expression Constraint
Represents a constraint that can be shipped to and asserted within a solver.
Definition solver.h:17
absl::btree_map< const IR::SymbolicVariable *, const IR::Expression *, IR::SymbolicVariableLess > SymbolicMapping
This type maps symbolic variables to their value assigned by the solver.
Definition solver.h:20