Skip to content

Keep short-circuit paths in statement-expression quantifier bodies - #9221

Open
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:kiro/9189-quantifier-stmt-expr
Open

tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:kiro/9189-quantifier-stmt-expr

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

When the body of __CPROVER_exists or __CPROVER_forall is a statement
expression, convert_statement_expression converts the body to a goto
program and collects "path condition implies value" for every path that
reaches the final expression. goto_convert converts that final
expression statement with its value unused. For a final expression such
as q < 4 && ({ ... }), the front end produces q < 4 ? ({ ... }) : false,
and with the value unused the false branch disappears: the path on which
q < 4 does not hold jumps past the final expression and contributes
nothing. The body a && b thus became a ==> b, and false exists and
forall assertions verified.

Assign the value of the final expression to a fresh temporary and use
that temporary as the final expression, so that both branches are
converted with their values used and every path reaches the final
expression.

A path that still bypasses the final expression, for example via a jump
past it, now results in an error: treating such a path as true is unsound
for assertions, treating it as false is unsound for assumptions.

The new test is tagged broken-z3-smt-backend like the other quantifier
tests, as Z3 returns a quantified expression as model value for these
properties.

Fixes #9189

  • 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.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

When the body of __CPROVER_exists or __CPROVER_forall is a statement
expression, convert_statement_expression converts the body to a goto
program and collects "path condition implies value" for every path that
reaches the final expression. goto_convert converts that final
expression statement with its value unused. For a final expression such
as q < 4 && ({ ... }), the front end produces q < 4 ? ({ ... }) : false,
and with the value unused the false branch disappears: the path on which
q < 4 does not hold jumps past the final expression and contributes
nothing. The body a && b thus became a ==> b, and false exists and
forall assertions verified.

Assign the value of the final expression to a fresh temporary and use
that temporary as the final expression, so that both branches are
converted with their values used and every path reaches the final
expression.

A path that still bypasses the final expression, for example via a jump
past it, now results in an error: treating such a path as true is unsound
for assertions, treating it as false is unsound for assumptions.

The new test is tagged broken-z3-smt-backend like the other quantifier
tests, as Z3 returns a quantified expression as model value for these
properties.

Fixes diffblue#9189

Co-authored-by: Kiro <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 19:38

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.75862% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.91%. Comparing base (266f438) to head (3217ae3).
⚠️ Report is 174 commits behind head on develop.

Files with missing lines Patch % Lines
src/ansi-c/goto-conversion/goto_clean_expr.cpp 82.75% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9221      +/-   ##
===========================================
- Coverage    80.91%   80.91%   -0.01%     
===========================================
  Files         1718     1718              
  Lines       190266   190292      +26     
  Branches        73       73              
===========================================
+ Hits        153952   153966      +14     
- Misses       36314    36326      +12     

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants