Skip to content

Batch Z3 model value requests and validate responses - #9160

Open
chaizhenhua wants to merge 1 commit into
diffblue:developfrom
chaizhenhua:fix/smt-z3-model-batch-20260910-upstream
Open

Batch Z3 model value requests and validate responses#9160
chaizhenhua wants to merge 1 commit into
diffblue:developfrom
chaizhenhua:fix/smt-z3-model-batch-20260910-upstream

Conversation

@chaizhenhua

Copy link
Copy Markdown

The SMT2 backend currently sends one get-value command per model identifier.
Z3 accepts one command containing the same sorted identifier set, so this change
batches that request and consumes every returned identifier/value pair through
the existing typed decoder. It also rejects malformed pairs, parser errors, and
missing requested values instead of accepting a partial SAT model.

This PR only changes the Z3 model request/response path. Singleton responses,
Boolean set_to fallback, UNSAT model errors, other solvers, use_as_const, and
the existing type encodings keep their current behavior.

Validation includes failing parent-linked unit regressions, SMT2/Z3/CORE unit
tests, cbmc-CORE, and smt2_solver-CORE. The wider Z3 run passed 1,102 cases
with 92 existing skips; complex2 exceeded 20 seconds on both the parent and
candidate and also exceeded 60 seconds on the candidate. On one 1,000-scalar
fixture, requests fell from 10,006 to 1 and seven alternating Z3 runs had median
wall times of 49.44 ms before and 41.78 ms after; this sample is not a general
performance claim.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures added are documented where their contract is non-obvious.
  • User guide: not applicable; this restores and validates internal SMT model decoding.
  • Regression and unit tests are included in the bug-fix commit.
  • The commit message contains the bounded performance data quoted above.
  • Restricted to one bug fix.
  • No unrelated whitespace changes.

The SMT2 backend currently writes one get-value command per identifier.
Request the same sorted identifier set in one Z3 command, and consume
every identifier/value pair through the existing typed model decoder.
Reject malformed pairs, parser errors and omitted requested typed values
instead of accepting a partial SAT model. Keep singleton responses,
Boolean set_to fallback, UNSAT model errors and other solvers' behavior.
Leave the current Z3 use_as_const setting and type encodings unchanged.

Add decision-table unit coverage for empty/singleton/multiple requests,
escaped identifiers, typed batched responses, invalid/missing responses,
and compatibility cases, plus a real Z3 model round trip. Relinking these
tests against the parent solver library reproduces the request assertion
failure and six malformed-response failures.

Validation: clang-format 15 changed-line check and cpplint pass;
[smt2] 308 assertions/46 cases; [z3] 27/7; [core] 18,839 assertions/595
cases, including two expected failures. CBMC CORE passes 1,128 tests
(67 skipped), and SMT2 solver CORE passes 42 (2 skipped). The wider Z3
CORE run passes 1,102 (92 skipped); complex2 times out at 20 seconds on
both parent and candidate and at 60 seconds on candidate. Its generated
formula is identical except for get-value grouping.

On one generated 1,000-scalar SAT fixture with Z3 4.15.4, requests fall
from 10,006 to 1, SMT input from 1,733,249 to 1,593,179 bytes and model
output from 324,598 to 314,593 bytes. Seven alternating Z3 runs have
median wall times 49.44/41.78 ms; five CBMC runs have medians
308.03/294.30 ms. Model assignments and decoded traces match exactly.
These local sample measurements do not establish a general speedup.
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.

1 participant