Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bool.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace smt_terms {
5using namespace smt_solver;
6
14class Bool {
15 public:
17 cvc5::Term term;
19 bool asserted = false;
20
21 Bool(const cvc5::Term& t, Solver* slv, TermType type = TermType::SBool)
22 : solver(slv)
23 , term(t)
24 , type(type) {};
25
26 explicit Bool(const STerm& t)
27 : solver(t.solver)
28 , term(t.normalize().term) {};
29
30 explicit Bool(const std::string& name, Solver* slv)
31 : solver(slv)
32 {
33 this->term = this->solver->term_manager.mkConst(this->solver->term_manager.getBooleanSort(), name);
34 }
35
36 explicit Bool(bool t, Solver* slv)
37 : solver(slv)
38 {
39 term = solver->term_manager.mkBoolean(t);
40 }
41 Bool(const Bool& other) = default;
42 Bool(Bool&& other) = default;
43
44 Bool& operator=(const Bool& right) = default;
45 Bool& operator=(Bool&& right) = default;
46
48 {
49 if (!asserted) {
51 asserted = true;
52 }
53 }
54
55 Bool operator|(const Bool& other) const;
56 void operator|=(const Bool& other);
57 Bool operator|(const bool& other) const;
58 void operator|=(const bool& other) const;
59
60 Bool operator&(const Bool& other) const;
61 void operator&=(const Bool& other);
62 Bool operator&(const bool& other) const;
63 void operator&=(const bool& other);
64
65 Bool operator!() const;
66
67 Bool operator==(const Bool& other) const;
68 Bool operator!=(const Bool& other) const;
69
70 operator std::string() const { return this->solver->stringify_term(term); };
71 operator cvc5::Term() const { return term; };
72
73 friend std::ostream& operator<<(std::ostream& out, const Bool& term)
74 {
75 return out << static_cast<std::string>(term);
76 };
77
78 friend Bool batch_or(const std::vector<Bool>& children)
79 {
80 Solver* s = children[0].solver;
81 std::vector<cvc5::Term> terms(children.begin(), children.end());
82 cvc5::Term res = s->term_manager.mkTerm(cvc5::Kind::OR, terms);
83 return { res, s };
84 }
85
86 friend Bool batch_and(const std::vector<Bool>& children)
87 {
88 Solver* s = children[0].solver;
89 std::vector<cvc5::Term> terms(children.begin(), children.end());
90 cvc5::Term res = s->term_manager.mkTerm(cvc5::Kind::AND, terms);
91 return { res, s };
92 }
93
94 ~Bool() = default;
95};
96}; // namespace smt_terms
Class for the solver.
Definition solver.hpp:80
void assertFormula(const cvc5::Term &term) const
Definition solver.hpp:158
cvc5::Solver solver
Definition solver.hpp:83
cvc5::TermManager term_manager
Definition solver.hpp:82
std::string stringify_term(const cvc5::Term &term, bool parenthesis=false)
Definition solver.cpp:235
Bool element class.
Definition bool.hpp:14
Solver * solver
Definition bool.hpp:16
friend std::ostream & operator<<(std::ostream &out, const Bool &term)
Definition bool.hpp:73
Bool(bool t, Solver *slv)
Definition bool.hpp:36
~Bool()=default
Bool operator|(const bool &other) const
Bool operator&(const Bool &other) const
Definition bool.cpp:17
TermType type
Definition bool.hpp:18
Bool operator!() const
Definition bool.cpp:41
friend Bool batch_or(const std::vector< Bool > &children)
Definition bool.hpp:78
bool asserted
Definition bool.hpp:19
Bool(const std::string &name, Solver *slv)
Definition bool.hpp:30
Bool & operator=(const Bool &right)=default
Bool(const cvc5::Term &t, Solver *slv, TermType type=TermType::SBool)
Definition bool.hpp:21
Bool(const STerm &t)
Definition bool.hpp:26
Bool(const Bool &other)=default
void assert_term()
Definition bool.hpp:47
Bool operator!=(const Bool &other) const
Definition bool.cpp:34
void operator|=(const bool &other) const
void operator|=(const Bool &other)
Definition bool.cpp:12
Bool & operator=(Bool &&right)=default
cvc5::Term term
Definition bool.hpp:17
void operator&=(const bool &other)
Bool(Bool &&other)=default
friend Bool batch_and(const std::vector< Bool > &children)
Definition bool.hpp:86
Bool operator==(const Bool &other) const
Definition bool.cpp:28
void operator&=(const Bool &other)
Definition bool.cpp:23
Bool operator&(const bool &other) const
Bool operator|(const Bool &other) const
Definition bool.cpp:5
Symbolic term element class.
Definition term.hpp:114
TermType
Allows to define three types of symbolic terms STerm - Symbolic Variables acting like a Finte Field e...
Definition term.hpp:15
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13