Implement SMT2 incremental support for arithmetic integers#8776
Open
tautschnig wants to merge 1 commit into
Open
Implement SMT2 incremental support for arithmetic integers#8776tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
9634f7e to
90f99e5
Compare
There was a problem hiding this comment.
Pull request overview
Adds SMT2 incremental support for mathematical integers (__CPROVER_integer) by introducing an integer SMT sort/term and an smt_integer_theory covering arithmetic and comparison operators.
Changes:
- Introduces
smt_int_sorttandsmt_int_constant_termt, plus SMT2 string serialization for the new sort/term. - Adds
smt_integer_theoryt(add/sub/mul/div/mod and comparisons) and wires integer type/constant conversion in the SMT backend. - Updates logic IDs and enables an existing regression to run with the SMT backend.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util/mathematical_types.h | Adds can_cast_type<integer_typet> to recognize ID_integer. |
| src/solvers/smt2_incremental/theories/smt_integer_theory.h | Declares integer arithmetic/comparison operator factories. |
| src/solvers/smt2_incremental/theories/smt_integer_theory.cpp | Implements integer theory identifiers, sorts, and validation. |
| src/solvers/smt2_incremental/smt_to_smt2_string.cpp | Prints SMT Int sort and integer constants. |
| src/solvers/smt2_incremental/convert_expr_to_smt.cpp | Maps integer_typet to Int, converts literals, and routes +/* to integer theory. |
| src/solvers/smt2_incremental/construct_value_expr_from_smt.cpp | Constructs __CPROVER_integer values from SMT int constants. |
| src/solvers/smt2_incremental/ast/smt_terms.h | Adds smt_int_constant_termt. |
| src/solvers/smt2_incremental/ast/smt_terms.def | Registers int_constant term kind. |
| src/solvers/smt2_incremental/ast/smt_terms.cpp | Implements smt_int_constant_termt storage/accessors. |
| src/solvers/smt2_incremental/ast/smt_sorts.h | Adds smt_int_sortt. |
| src/solvers/smt2_incremental/ast/smt_sorts.def | Registers int sort kind. |
| src/solvers/smt2_incremental/ast/smt_sorts.cpp | Implements smt_int_sortt constructor. |
| src/solvers/smt2_incremental/ast/smt_logics.def | Adds QF_UFLIA and QF_AUFLIA logic IDs. |
| src/solvers/Makefile | Builds the new smt_integer_theory.cpp. |
| regression/cbmc/integer-assignments1/test.desc | Enables the test for the SMT backend (removes no-new-smt). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
90f99e5 to
f9fada8
Compare
f9fada8 to
9e32363
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #8776 +/- ##
===========================================
+ Coverage 80.72% 80.74% +0.01%
===========================================
Files 1714 1716 +2
Lines 189915 190196 +281
Branches 73 73
===========================================
+ Hits 153311 153573 +262
- Misses 36604 36623 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Adds support for mathematical integers (`__CPROVER_integer`) to the incremental SMT2 back-end via a new smt_integer_theory. The converter routes addition, subtraction, multiplication, unary minus, the relational operators (<, <=, >, >=) and integer division/modulo on integer-typed operands to this theory. SMT-LIB Int `div`/`mod` are Euclidean, whereas CBMC's `div_exprt`/`mod_exprt` truncate toward zero (see the mod_exprt documentation in util/std_expr.h). The converter therefore applies the same sign correction as the non-incremental smt2_convt: division divides the operand magnitudes and negates the quotient iff the operands have opposite signs, and modulo takes the remainder of the magnitudes and re-applies the dividend's sign. `euclidean_mod_exprt` maps directly to SMT-LIB `mod`, which already matches its Euclidean semantics. The QF_UFLIA/QF_AUFLIA logic identifiers are added for completeness/future logic selection; the decision procedure currently emits `(set-logic ALL)`. Covered by the regression/cbmc-incr-smt2/integer-operators and integer-division tests (run under the incremental SMT2 back-end) and by unit tests for the integer theory (including div/mod), the truncation/Euclidean conversion encodings, the Int sort / integer-constant serialization, and integer-constant response validation. Fixes: diffblue#8074 Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
9e32363 to
5d922fa
Compare
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.
Adds support for mathematical integers (
__CPROVER_integer) via a new smt_integer_theory with arithmetic and comparison operators.Fixes: #8074