Skip to content

Incremental SMT2: Lazy array instantiation for array_of expressions#8899

Draft
tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig:fix-8061-lazy-array_of
Draft

Incremental SMT2: Lazy array instantiation for array_of expressions#8899
tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig:fix-8061-lazy-array_of

Conversation

@tautschnig
Copy link
Copy Markdown
Collaborator

Replace the universal quantifier (forall) encoding for array_of_exprt with targeted index-specific assertions. Instead of asserting that every element equals the fill value upfront, track which indices are actually accessed and only assert the fill value for those specific indices.

This eliminates smt_forall_termt usage for array_of, improving SMT solver performance (especially with 64-bit indices) and avoiding potential 'unknown' results from solvers that struggle with quantifiers combined with arrays and bit vectors.

New data structures:

  • array_of_fill_values: maps array identifier to its fill value term
  • array_of_instantiated_indices: tracks which indices have been asserted

New methods:

  • instantiate_array_of_for_index: sends a single select=fill assertion
  • instantiate_lazy_array_of_indices: scans expressions for index_exprt nodes accessing array_of arrays and triggers lazy instantiation

The lazy instantiation is called from both set_to and ensure_handle_for_expr_defined after define_dependent_functions.

Fixes: #8061

  • 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.

Replace the universal quantifier (forall) encoding for array_of_exprt
with targeted index-specific assertions. Instead of asserting that every
element equals the fill value upfront, track which indices are actually
accessed and only assert the fill value for those specific indices.

This eliminates smt_forall_termt usage for array_of, improving SMT
solver performance (especially with 64-bit indices) and avoiding
potential 'unknown' results from solvers that struggle with quantifiers
combined with arrays and bit vectors.

New data structures:
- array_of_fill_values: maps array identifier to its fill value term
- array_of_instantiated_indices: tracks which indices have been asserted

New methods:
- instantiate_array_of_for_index: sends a single select=fill assertion
- instantiate_lazy_array_of_indices: scans expressions for index_exprt
  nodes accessing array_of arrays and triggers lazy instantiation

The lazy instantiation is called from both set_to and
ensure_handle_for_expr_defined after define_dependent_functions.

Fixes: diffblue#8061
@tautschnig tautschnig self-assigned this Mar 27, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.42%. Comparing base (59d2211) to head (5dd6bb6).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8899   +/-   ##
========================================
  Coverage    80.41%   80.42%           
========================================
  Files         1703     1703           
  Lines       188398   188489   +91     
  Branches        73       73           
========================================
+ Hits        151502   151590   +88     
- Misses       36896    36899    +3     

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

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.

SMT solver performance issue with the encoding of array_of expressions in incremental smt2 decision procedure

1 participant