barretenberg
Loading...
Searching...
No Matches
bool.hpp
1#pragma once
2#include "ffiterm.hpp"
3#include "ffterm.hpp"
4
5namespace smt_terms {
6using namespace smt_solver;
7
15class Bool {
16 public:
17 cvc5::Solver* solver;
18 cvc5::Term term;
19 bool asserted = false;
20
21 explicit Bool(const cvc5::Term& t, Solver& slv)
22 : solver(&slv.s)
23 , term(t){};
24 explicit Bool(const FFTerm& t)
25 : solver(&t.solver->s)
26 , term(t.term){};
27
28 explicit Bool(const FFITerm& t)
29 : solver(&t.solver->s)
30 , term(t.term){};
31
32 explicit Bool(bool t, Solver& slv)
33 : solver(&slv.s)
34 {
35 term = solver->mkBoolean(t);
36 }
37 Bool(const cvc5::Term& term, cvc5::Solver* s)
38 : solver(s)
39 , term(term){};
40 Bool(const Bool& other) = default;
41 Bool(Bool&& other) = default;
42
43 Bool& operator=(const Bool& right) = default;
44 Bool& operator=(Bool&& right) = default;
45
46 void assert_term()
47 {
48 if (!asserted) {
49 solver->assertFormula(term);
50 asserted = true;
51 }
52 }
53
54 Bool operator|(const Bool& other) const;
55 void operator|=(const Bool& other);
56 Bool operator|(const bool& other) const;
57 void operator|=(const bool& other) const;
58
59 Bool operator&(const Bool& other) const;
60 void operator&=(const Bool& other);
61 Bool operator&(const bool& other) const;
62 void operator&=(const bool& other);
63
64 Bool operator==(const Bool& other) const;
65 Bool operator!=(const Bool& other) const;
66
67 operator std::string() const { return term.toString(); };
68 operator cvc5::Term() const { return term; };
69
70 friend Bool batch_or(const std::vector<Bool>& children)
71 {
72 cvc5::Solver* s = children[0].solver;
73 std::vector<cvc5::Term> terms(children.begin(), children.end());
74 cvc5::Term res = s->mkTerm(cvc5::Kind::OR, terms);
75 return { res, s };
76 }
77
78 friend Bool batch_and(const std::vector<Bool>& children)
79 {
80 cvc5::Solver* s = children[0].solver;
81 std::vector<cvc5::Term> terms(children.begin(), children.end());
82 cvc5::Term res = s->mkTerm(cvc5::Kind::AND, terms);
83 return { res, s };
84 }
85
86 ~Bool() = default;
87};
88}; // namespace smt_terms
Class for the solver.
Definition: solver.hpp:28
Bool element class.
Definition: bool.hpp:15
Integer Modulo element class.
Definition: ffiterm.hpp:16
Finite Field element class.
Definition: ffterm.hpp:15