Skip to content

Add string type support to SMT back-end#8838

Open
tautschnig wants to merge 2 commits intodiffblue:developfrom
tautschnig:smt-strings
Open

Add string type support to SMT back-end#8838
tautschnig wants to merge 2 commits intodiffblue:developfrom
tautschnig:smt-strings

Conversation

@tautschnig
Copy link
Collaborator

We can safely thread through string operations to the back-end as SMT solvers now have support for the theory of strings.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a 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.

We can safely thread through string operations to the back-end as SMT
solvers now have support for the theory of strings.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds basic string type support to the SMT2 backend solver, enabling SMT solvers to handle string operations using the SMT-LIB theory of strings.

Changes:

  • Added support for converting string types to SMT2 "String" type
  • Implemented string constant conversion with escaping for double quotes and backslashes
  • Added special handling for Str.Concat function application to convert to SMT-LIB str.++ operator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2717 to +2723
if(fn_name == "Str.Concat" &&
function_application_expr.arguments().size() == 2)
{
out << "(str.++ ";
convert_expr(function_application_expr.arguments()[0]);
out << ' ';
convert_expr(function_application_expr.arguments()[1]);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The str.++ (string concatenation) operation in SMT-LIB 2 can take any number of arguments (including 0, 1, or more than 2), but this implementation only handles exactly 2 arguments. When there are != 2 arguments, it falls through to the else case which will output "Str.Concat" instead of "str.++". Consider removing the size check or handling variable numbers of arguments to ensure all Str.Concat calls are properly converted to str.++.

Suggested change
if(fn_name == "Str.Concat" &&
function_application_expr.arguments().size() == 2)
{
out << "(str.++ ";
convert_expr(function_application_expr.arguments()[0]);
out << ' ';
convert_expr(function_application_expr.arguments()[1]);
if(fn_name == "Str.Concat")
{
out << "(str.++";
for(const auto &op : function_application_expr.arguments())
{
out << ' ';
convert_expr(op);
}

Copilot uses AI. Check for mistakes.
UNEXPECTEDCASE("unsuppored range type");
out << "(_ BitVec " << address_bits(size) << ")";
}
else if(type.id()==ID_string)
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

Inconsistent spacing around the == operator. The codebase convention in this file is to use no spaces (e.g., type.id()==ID_string on line 6025, expr_type.id()==ID_string on line 3782). This line has spaces around == which is inconsistent with the rest of the file.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 27.27273% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.00%. Comparing base (15eb10a) to head (84732a2).

Files with missing lines Patch % Lines
src/solvers/smt2/smt2_conv.cpp 27.27% 16 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8838      +/-   ##
===========================================
- Coverage    80.00%   80.00%   -0.01%     
===========================================
  Files         1700     1700              
  Lines       188252   188273      +21     
  Branches        73       73              
===========================================
+ Hits        150613   150621       +8     
- Misses       37639    37652      +13     

☔ 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.

@tautschnig tautschnig self-assigned this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants