Skip to content

SMT2: avoid emitting unary bitvector concat#8997

Merged
kroening merged 1 commit intodevelopfrom
fix/no-unary-bv-concat-smt2
May 3, 2026
Merged

SMT2: avoid emitting unary bitvector concat#8997
kroening merged 1 commit intodevelopfrom
fix/no-unary-bv-concat-smt2

Conversation

@kroening
Copy link
Copy Markdown
Collaborator

@kroening kroening commented May 1, 2026

When zero-width operands are dropped from a concatenation expression, the remaining operands may reduce to a single one. Previously this produced invalid (concat x) in the SMT-LIB output. Now the single operand is emitted directly.

Changes

  • src/solvers/smt2/smt2_conv.cpp: Collect non-zero-width operands first; emit directly if only one remains.
  • unit/solvers/smt2/smt2_conv.cpp: Add unit test with a zero-width bitvector operand asserting the generated string.

@kroening kroening force-pushed the fix/no-unary-bv-concat-smt2 branch 2 times, most recently from 39bd6c7 to 441aac1 Compare May 1, 2026 17:01
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.51%. Comparing base (4993eb9) to head (425b797).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8997      +/-   ##
===========================================
- Coverage    80.51%   80.51%   -0.01%     
===========================================
  Files         1704     1704              
  Lines       188874   188885      +11     
  Branches        73       73              
===========================================
+ Hits        152076   152083       +7     
- Misses       36798    36802       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/solvers/smt2/smt2_conv.cpp Outdated
Comment on lines +1314 to +1319
if(non_zero_width_ops.size() <= 1)
{
// unary concat is not valid SMT-LIB; emit the operand directly
if(non_zero_width_ops.size() == 1)
flatten2bv(non_zero_width_ops.front());
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the DATA_INVARIANT on line 1310 guarantees !non_zero_width_ops.empty(), the only value that satisfies size() <= 1 is size() == 1:

Suggested change
if(non_zero_width_ops.size() <= 1)
{
// unary concat is not valid SMT-LIB; emit the operand directly
if(non_zero_width_ops.size() == 1)
flatten2bv(non_zero_width_ops.front());
}
if(non_zero_width_ops.size() == 1)
{
// unary concat is not valid SMT-LIB; emit the operand directly
flatten2bv(non_zero_width_ops.front());
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

When zero-width operands are dropped from a concatenation expression,
the result may be a single operand. Emit it directly instead of
producing invalid (concat x) in the SMT-LIB output.
@kroening kroening force-pushed the fix/no-unary-bv-concat-smt2 branch from 1440225 to 425b797 Compare May 2, 2026 00:42
@kroening kroening merged commit b875a22 into develop May 3, 2026
62 of 63 checks passed
@kroening kroening deleted the fix/no-unary-bv-concat-smt2 branch May 3, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants