barretenberg
Loading...
Searching...
No Matches
solver.hpp
1#pragma once
2#include <cvc5/cvc5.h>
3#include <string>
4#include <unordered_map>
5
6namespace smt_solver {
7
17 bool produce_model;
18 uint64_t timeout;
19};
20
28class Solver {
29 public:
30 cvc5::Solver s;
31 cvc5::Sort fp;
32 std::string modulus; // modulus in base 10
33 bool res = false;
34 bool checked = false;
35
36 explicit Solver(const std::string& modulus, const SolverConfiguration& config = { false, 0 }, uint32_t base = 16)
37 {
38 this->fp = s.mkFiniteFieldSort(modulus, base);
39 this->modulus = fp.getFiniteFieldSize();
40 if (config.produce_model) {
41 s.setOption("produce-models", "true");
42 }
43 if (config.timeout > 0) {
44 s.setOption("tlimit-per", std::to_string(config.timeout));
45 }
46 }
47
48 Solver(const Solver& other) = delete;
49 Solver(Solver&& other) = delete;
50 Solver& operator=(const Solver& other) = delete;
51 Solver& operator=(Solver&& other) = delete;
52
53 bool check();
54
55 [[nodiscard]] std::string getResult() const
56 {
57 if (!checked) {
58 return "No result, yet";
59 }
60 return res ? "SAT" : "UNSAT";
61 }
62
63 std::unordered_map<std::string, std::string> model(std::unordered_map<std::string, cvc5::Term>& terms) const;
64 ~Solver() = default;
65};
66}; // namespace smt_solver
Class for the solver.
Definition: solver.hpp:28
std::unordered_map< std::string, std::string > model(std::unordered_map< std::string, cvc5::Term > &terms) const
Definition: solver.cpp:25
bool check()
Definition: solver.cpp:11
Solver configuration.
Definition: solver.hpp:16