-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Several updates in SMT verification module #7105
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fbf4903
Not needed anymore
Sarkoxed b762da9
Owerflowed bitvector and optimizations
Sarkoxed 940698c
Logging issues
Sarkoxed 71077bb
Added unsigned division
Sarkoxed 7190e98
New Term class and bug fixes
Sarkoxed c56fff5
Colored output + fix_range_lists function
Sarkoxed 46a51bc
New iterm class tests
Sarkoxed d5773ef
Updated readme file
Sarkoxed a7183f9
formatting
Sarkoxed 4df96ee
Merge branch 'master' into as/smt-verification-upmodule-update-4
Sarkoxed c54f7b8
checks didn't start..
Sarkoxed a937f0e
Iterm
Sarkoxed 1902b3c
Merge branch 'master' into as/smt-verification-upmodule-update-4
Rumata888 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
166 changes: 121 additions & 45 deletions
166
barretenberg/cpp/src/barretenberg/smt_verification/README.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
barretenberg/cpp/src/barretenberg/smt_verification/terms/iterm.test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#include <unordered_map> | ||
|
||
#include "barretenberg/stdlib/primitives/uint/uint.hpp" | ||
#include "term.hpp" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace { | ||
auto& engine = bb::numeric::get_debug_randomness(); | ||
} | ||
|
||
using namespace bb; | ||
using witness_ct = stdlib::witness_t<StandardCircuitBuilder>; | ||
|
||
using namespace smt_terms; | ||
|
||
TEST(ITerm, addition) | ||
{ | ||
StandardCircuitBuilder builder; | ||
uint64_t a = static_cast<uint32_t>(fr::random_element()) % (static_cast<uint32_t>(1) << 31); | ||
uint64_t b = static_cast<uint32_t>(fr::random_element()) % (static_cast<uint32_t>(1) << 31); | ||
uint64_t c = a + b; | ||
|
||
Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", default_solver_config); | ||
|
||
STerm x = IVar("x", &s); | ||
STerm y = IVar("y", &s); | ||
STerm z = x + y; | ||
|
||
z == c; | ||
x == a; | ||
ASSERT_TRUE(s.check()); | ||
|
||
std::string yvals = s.getValue(y.term).getIntegerValue(); | ||
|
||
STerm bval = STerm(b, &s, TermType::ITerm); | ||
std::string bvals = s.getValue(bval.term).getIntegerValue(); | ||
ASSERT_EQ(bvals, yvals); | ||
} | ||
|
||
TEST(ITerm, subtraction) | ||
{ | ||
StandardCircuitBuilder builder; | ||
uint64_t c = static_cast<uint32_t>(fr::random_element()) % (static_cast<uint32_t>(1) << 31); | ||
uint64_t b = static_cast<uint32_t>(fr::random_element()) % (static_cast<uint32_t>(1) << 31); | ||
uint64_t a = c + b; | ||
|
||
Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", default_solver_config); | ||
|
||
STerm x = IVar("x", &s); | ||
STerm y = IVar("y", &s); | ||
STerm z = x - y; | ||
|
||
x == a; | ||
z == c; | ||
ASSERT_TRUE(s.check()); | ||
|
||
std::string yvals = s.getValue(y.term).getIntegerValue(); | ||
|
||
STerm bval = STerm(b, &s, TermType::ITerm); | ||
std::string bvals = s.getValue(bval.term).getIntegerValue(); | ||
ASSERT_EQ(bvals, yvals); | ||
} | ||
|
||
TEST(ITerm, mul) | ||
{ | ||
StandardCircuitBuilder builder; | ||
uint64_t a = static_cast<uint32_t>(fr::random_element()) % (static_cast<uint32_t>(1) << 31); | ||
uint64_t b = static_cast<uint32_t>(fr::random_element()) % (static_cast<uint32_t>(1) << 31); | ||
uint64_t c = a * b; | ||
|
||
Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", default_solver_config); | ||
|
||
STerm x = IVar("x", &s); | ||
STerm y = IVar("y", &s); | ||
STerm z = x * y; | ||
|
||
x == a; | ||
y == b; | ||
|
||
ASSERT_TRUE(s.check()); | ||
|
||
std::string xvals = s.getValue(z.term).getIntegerValue(); | ||
STerm bval = STerm(c, &s, TermType::ITerm); | ||
std::string bvals = s.getValue(bval.term).getIntegerValue(); | ||
ASSERT_EQ(bvals, xvals); | ||
} | ||
|
||
TEST(ITerm, div) | ||
{ | ||
StandardCircuitBuilder builder; | ||
uint64_t a = static_cast<uint32_t>(fr::random_element()) % (static_cast<uint32_t>(1) << 31); | ||
uint64_t b = static_cast<uint32_t>(fr::random_element()) % (static_cast<uint32_t>(1) << 31) + 1; | ||
uint64_t c = a / b; | ||
|
||
Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", default_solver_config); | ||
|
||
STerm x = IVar("x", &s); | ||
STerm y = IVar("y", &s); | ||
STerm z = x / y; | ||
|
||
x == a; | ||
y == b; | ||
|
||
ASSERT_TRUE(s.check()); | ||
|
||
std::string xvals = s.getValue(z.term).getIntegerValue(); | ||
STerm bval = STerm(c, &s, TermType::ITerm); | ||
std::string bvals = s.getValue(bval.term).getIntegerValue(); | ||
ASSERT_EQ(bvals, xvals); | ||
} | ||
|
||
// This test aims to check for the absence of unintended | ||
// behavior. If an unsupported operator is called, an info message appears in stderr | ||
// and the value is supposed to remain unchanged. | ||
TEST(ITerm, unsupported_operations) | ||
{ | ||
Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"); | ||
|
||
STerm x = IVar("x", &s); | ||
STerm y = IVar("y", &s); | ||
|
||
STerm z = x ^ y; | ||
ASSERT_EQ(z.term, x.term); | ||
z = x & y; | ||
ASSERT_EQ(z.term, x.term); | ||
z = x | y; | ||
ASSERT_EQ(z.term, x.term); | ||
z = x >> 10; | ||
ASSERT_EQ(z.term, x.term); | ||
z = x << 10; | ||
ASSERT_EQ(z.term, x.term); | ||
z = x.rotr(10); | ||
ASSERT_EQ(z.term, x.term); | ||
z = x.rotl(10); | ||
ASSERT_EQ(z.term, x.term); | ||
|
||
cvc5::Term before_term = x.term; | ||
x ^= y; | ||
ASSERT_EQ(x.term, before_term); | ||
x &= y; | ||
ASSERT_EQ(x.term, before_term); | ||
x |= y; | ||
ASSERT_EQ(x.term, before_term); | ||
x >>= 10; | ||
ASSERT_EQ(x.term, before_term); | ||
x <<= 10; | ||
ASSERT_EQ(x.term, before_term); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rename to "enable_optimisations", since this is a flag