Skip to content
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

SMT2: support onehot and onehot0 #8524

Merged
merged 1 commit into from
Dec 3, 2024
Merged

SMT2: support onehot and onehot0 #8524

merged 1 commit into from
Dec 3, 2024

Conversation

kroening
Copy link
Member

@kroening kroening commented Dec 1, 2024

This adds support for the onehot and onehot0 predicates to the SMT2 backend.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link

codecov bot commented Dec 1, 2024

Codecov Report

Attention: Patch coverage is 77.08333% with 22 lines in your changes missing coverage. Please review.

Project coverage is 78.46%. Comparing base (c902db3) to head (7e39d04).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
src/util/bitvector_expr.h 50.00% 8 Missing ⚠️
src/util/bitvector_expr.cpp 73.91% 6 Missing ⚠️
src/solvers/smt2/smt2_conv.cpp 40.00% 3 Missing ⚠️
unit/util/bitvector_expr.cpp 93.75% 3 Missing ⚠️
src/solvers/flattening/boolbv.cpp 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8524      +/-   ##
===========================================
- Coverage    78.88%   78.46%   -0.42%     
===========================================
  Files         1728     1728              
  Lines       198669   199820    +1151     
  Branches     18393    18356      -37     
===========================================
+ Hits        156719   156792      +73     
- Misses       41950    43028    +1078     

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

Comment on lines +1834 to +1837
else if(expr.id() == ID_onehot)
{
convert_expr(to_onehot_expr(expr).lower());
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about ID_onehot0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added, thank you

{
exprt one_seen = false_exprt{};
const auto width = to_bitvector_type(expr.type()).get_width();
exprt::operandst more_than_one_seen_disjuncts;
Copy link
Collaborator

Choose a reason for hiding this comment

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

May I suggest more_than_one_seen_disjuncts.reserve(width);?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -64,3 +71,34 @@ TEMPLATE_TEST_CASE(
}
}
}

TEST_CASE("onehot expression lowering", "[core][util][expr]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for adding this test; but could onehot0 please also be included?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

This adds support for the onehot and onehot0 predicates to the SMT2 backend.
@tautschnig tautschnig removed their assignment Dec 2, 2024
@kroening kroening merged commit 7eef276 into develop Dec 3, 2024
39 of 41 checks passed
@kroening kroening deleted the smt2-onehot branch December 3, 2024 12: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.

4 participants