Skip to content

SMT2: encode mathematical and string/regex types and operations#9074

Open
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:strata/smt2-mathematical-and-string-types
Open

SMT2: encode mathematical and string/regex types and operations#9074
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:strata/smt2-mathematical-and-string-types

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

Convert mathematical integer/real types to SMT-LIB Int/Real (type2id, convert_type), encode mathematical mod/div semantics, string/regex types, string constants, and map Strata's Str./Re. function applications to the corresponding SMT-LIB string/regex operators in convert_expr.

  • 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.
  • 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).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Convert mathematical integer/real types to SMT-LIB Int/Real (type2id,
convert_type), encode mathematical mod/div semantics, string/regex types,
string constants, and map Strata's Str.*/Re.* function applications to the
corresponding SMT-LIB string/regex operators in convert_expr.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig tautschnig self-assigned this Jun 18, 2026
Copilot AI review requested due to automatic review settings June 18, 2026 21:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Extends the SMT2 converter to support Strata mathematical Int/Real types plus SMT-LIB string/regex types, constants, and common Str.* / Re.* operations.

Changes:

  • Encode integer, real, string, and regex sorts in type2id / convert_type
  • Map selected Str.* and Re.* function applications to SMT-LIB string/regex operators
  • Adjust integer div/mod encoding and add SMT-LIB string constant emission

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

Comment on lines +3880 to +3894
else if(expr_type.id()==ID_string)
{
const std::string &value = id2string(expr.get_value());
out << "\"";
for(char c : value)
{
if(c == '"')
out << "\"\"";
else if(c == '\\')
out << "\\\\";
else
out << c;
}
out << "\"";
}
Comment on lines +3929 to +3942
else if(expr.type().id() == ID_integer)
{
// SMT-LIB2 mod for mathematical integers (truncation semantics)
// Use (- a (* (div a b) b)) to get truncation mod
out << "(- ";
convert_expr(expr.op0());
out << " (* (div ";
convert_expr(expr.op0());
out << " ";
convert_expr(expr.op1());
out << ") ";
convert_expr(expr.op1());
out << "))";
}
Comment on lines +2718 to +2751
// Map Strata function names to SMT-LIB names for string/regex ops
std::string smt_name;
if(fn_name == "Str.Concat")
smt_name = "str.++";
else if(fn_name == "Str.Length")
smt_name = "str.len";
else if(fn_name == "Str.Substr")
smt_name = "str.substr";
else if(fn_name == "Str.ToRegEx")
smt_name = "str.to_re";
else if(fn_name == "Str.InRegEx")
smt_name = "str.in_re";
else if(fn_name == "Re.AllChar")
smt_name = "re.allchar";
else if(fn_name == "Re.All")
smt_name = "re.all";
else if(fn_name == "Re.Range")
smt_name = "re.range";
else if(fn_name == "Re.Concat")
smt_name = "re.concat";
else if(fn_name == "Re.Star")
smt_name = "re.*";
else if(fn_name == "Re.Plus")
smt_name = "re.+";
else if(fn_name == "Re.Loop")
smt_name = "re.loop";
else if(fn_name == "Re.Union")
smt_name = "re.union";
else if(fn_name == "Re.Inter")
smt_name = "re.inter";
else if(fn_name == "Re.Comp")
smt_name = "re.comp";
else if(fn_name == "Re.None")
smt_name = "re.none";
Comment on lines +4479 to +4483
if(
expr.type().id() == ID_integer || expr.type().id() == ID_natural)
{
out << "(div ";
}
fn_name = id2string(
to_symbol_expr(function_application_expr.function()).get_identifier());

// Map Strata function names to SMT-LIB names for string/regex ops

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.

We should introduce expressions for these at some point.

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.

3 participants