Add .lower() methods to reduction and replication expressions#9123
Open
kroening wants to merge 1 commit into
Open
Add .lower() methods to reduction and replication expressions#9123kroening wants to merge 1 commit into
kroening wants to merge 1 commit into
Conversation
kroening
requested review from
TGWDB,
martin-cs,
peterschrammel and
tautschnig
as code owners
July 21, 2026 11:30
kroening
force-pushed
the
kroening/bitvector-expr-lower-methods
branch
3 times, most recently
from
July 21, 2026 12:18
acf1879 to
3961543
Compare
Add lower() methods to reduction_and_exprt, reduction_nand_exprt, reduction_or_exprt, reduction_nor_exprt, reduction_xor_exprt, reduction_xnor_exprt, and replication_exprt in bitvector_expr.h/cpp. These methods lower high-level bitvector reduction and replication operators to simpler expression forms: - reduction_and(a) → (a = all_ones) - reduction_nand(a) → (a != all_ones) - reduction_or(a) → (a != 0) - reduction_nor(a) → (a = 0) - reduction_xor(a) → a[0] ^ a[1] ^ ... ^ a[n-1] - reduction_xnor(a) → !(a[0] ^ a[1] ^ ... ^ a[n-1]) - replication(n, x) → x :: x :: ... :: x (n times) Use the new .lower() methods in smt2_conv.cpp to replace inline lowering code for reduction_and, reduction_nand, reduction_or, reduction_nor, and reduction_xnor. The reduction_xor case retains its native SMT-LIB encoding using extract + bvxor for efficiency.
kroening
force-pushed
the
kroening/bitvector-expr-lower-methods
branch
from
July 21, 2026 12:22
3961543 to
67842c6
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9123 +/- ##
===========================================
- Coverage 80.83% 80.82% -0.01%
===========================================
Files 1715 1715
Lines 189948 189979 +31
Branches 73 73
===========================================
+ Hits 153540 153547 +7
- Misses 36408 36432 +24 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add
lower()methods toreduction_and_exprt,reduction_nand_exprt,reduction_or_exprt,reduction_nor_exprt,reduction_xor_exprt,reduction_xnor_exprt, andreplication_exprtinbitvector_expr.h/bitvector_expr.cpp.These methods lower high-level bitvector reduction and replication operators to simpler expression forms:
reduction_and(a)→(a = all_ones)reduction_nand(a)→(a != all_ones)reduction_or(a)→(a != 0)reduction_nor(a)→(a = 0)reduction_xor(a)→a[0] ^ a[1] ^ ... ^ a[n-1]reduction_xnor(a)→!(a[0] ^ a[1] ^ ... ^ a[n-1])replication(n, x)→x :: x :: ... :: x(n times)Use the new
.lower()methods insmt2_conv.cppto replace inline lowering code forreduction_and,reduction_nand,reduction_or,reduction_nor, andreduction_xnor. Thereduction_xorcase retains its native SMT-LIB encoding usingextract+bvxorfor efficiency.The boolbv layer is not changed since it operates at the propositional literal level, and the SMT2 replication keeps its native
repeatoperator.Companion to diffblue/hw-cbmc#2037 which will use these methods via
.lower()instead of free functions.