Skip to content

Detect binder origins in SMT value definitions - #9162

Open
chaizhenhua wants to merge 1 commit into
diffblue:developfrom
chaizhenhua:fix/smt-binder-value-origin-20260910-upstream
Open

chaizhenhua wants to merge 1 commit into
diffblue:developfrom
chaizhenhua:fix/smt-binder-value-origin-20260910-upstream

Conversation

@chaizhenhua

Copy link
Copy Markdown

Z3 rejects get-value queries when a referenced definition expands to a
quantifier or lambda. The existing lambda workaround routed every typed Z3
assignment through declare-fun plus an equality assertion, while Boolean
handles only detected quantifiers. As a result, Boolean expressions containing
array comprehensions could still create rejected definitions, and binder-free
typed assignments unnecessarily changed form.

This change extends the existing recursive quantifier check into the single
binder-origin check used by both Boolean handles and typed assignments. Array
comprehensions count as binders only for a backend that emits them as lambdas.
Definitions containing binders use declare-fun plus assert; ordinary typed
Z3 definitions retain define-fun. The existing z3-lambda-unflatten
regression remains the end-to-end output contract.

Validation:

  • New decision-table unit test: 1 case, 10 assertions passed.

  • Exact old-production mutant: 5 of 10 assertions failed, covering the missed
    Boolean binder origin and the over-broad binder-free typed path.

  • [smt2]: 40 cases, 201 assertions passed.

  • [z3]: 6 cases, 22 assertions passed with Z3 4.15.4.

  • [core]: 590 cases; 588 passed and 2 existing expected failures; 18,737
    assertions.

  • z3-lambda-unflatten: passed.

  • Real Z3 z3-lambda-unflatten verification: 16 of 16 properties passed.

  • cbmc-CORE: 1,128 passed, 67 existing skips.

  • smt2_solver-CORE: 42 passed, 2 existing skips.

  • clang-format 15 changed-line check, diff-filtered cpplint, and git diff --check: passed.

  • Each commit message has a non-empty body, explaining why the change was made.

  • The added helper is private and its purpose is documented at its call sites.

  • No user-visible language or command-line behavior requires a User Guide update.

  • Unit and regression coverage is included.

  • No performance improvement is claimed.

  • The PR is restricted to one SMT value-definition bugfix.

  • There are no unrelated whitespace or formatting changes.

Z3 rejects get-value queries whose expanded definitions contain quantifiers or
lambdas. Extend the existing quantifier traversal to recognize array
comprehensions when they lower to lambdas, and use it at both Boolean and typed
value origins. This preserves define-fun for ordinary Z3 values while keeping
binders behind declare-fun plus an equality assertion.

Tests cover Boolean binder origins, typed binder origins, the binder-free
control, the existing lambda-unflatten regression, real Z3 solving, and the
CBMC and SMT2 solver CORE suites.
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