P4C
The P4 Compiler
Loading...
Searching...
No Matches
solver.h
1/*
2 * SPDX-FileCopyrightText: 2023 The P4 Language Consortium
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef IR_SOLVER_H_
8#define IR_SOLVER_H_
9
10#include <optional>
11#include <vector>
12
13#include "ir/compare.h"
14#include "ir/ir.h"
15#include "lib/castable.h"
16#include "lib/cstring.h"
17#include "lib/flat_map.h"
18
19namespace P4 {
20
22// TODO: This should implement AbstractRepCheckedNode<Constraint>.
23using Constraint = IR::Expression;
24
28
30class AbstractSolver : public ICastable {
31 public:
34 virtual void comment(cstring comment) = 0;
35
38 virtual void seed(unsigned seed) = 0;
39
41 virtual void timeout(unsigned tm) = 0;
42
48 virtual std::optional<bool> checkSat(const std::vector<const Constraint *> &asserts) = 0;
49
56 [[nodiscard]] virtual const SymbolicMapping &getSymbolicMapping() const = 0;
57
59 virtual void toJSON(JSONGenerator &) const = 0;
60
62 [[nodiscard]] virtual bool isInIncrementalMode() const = 0;
63
64 DECLARE_TYPEINFO(AbstractSolver);
65};
66
67} // namespace P4
68
69#endif /* IR_SOLVER_H_ */
Provides a higher-level interface for an SMT solver.
Definition solver.h:30
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:27
Definition json_generator.h:30
Definition cstring.h:85
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
IR::Expression Constraint
Represents a constraint that can be shipped to and asserted within a solver.
Definition solver.h:23
P4::flat_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:26
Definition flat_map.h:29