Skip to content

Improve qe-light elimination for BV vars constrained by constant (dis)equalities#9359

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-apply-qe-performance
Draft

Improve qe-light elimination for BV vars constrained by constant (dis)equalities#9359
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-apply-qe-performance

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

apply qe on a small BV existential formula could stall in practice, while the same shape is easy to simplify by case analysis on a small set of constant comparisons. This change teaches qe-light to recognize and eliminate that pattern directly.

  • BV case-split expansion in qe-light

    • Added a bounded fallback in src/qe/lite/qe_lite_tactic.cpp for quantified BV variables that occur only in equalities with constants (including under negation).
    • For each such variable, enumerate:
      • each observed constant case, plus
      • one synthesized “default” value distinct from those constants.
    • Substitute each case into the body and disjoin the instantiated formulas, yielding a quantifier-free result when applicable.
    • Added hard bounds to prevent blowups:
      • per-variable case cap
      • total Cartesian-product case cap
  • Integration point

    • Wired this BV expansion into the existing post-eq_der/FM quantifier reduction path, as a fallback alongside existing bounded-expansion logic.
  • Regression coverage

    • Added a focused test in src/test/qe_arith.cpp using a minimized BV formula with the same structural pattern as the reported repro.
    • The test asserts:
      • quantifiers are eliminated by qe_lite
      • rewritten formula remains equivalent to the original quantified formula.
if (m_imp.try_expand_bounded_quantifier(q, result, expanded) ||
    m_imp.try_expand_bv_eq_quantifier(q, result, expanded)) {
    ...
}

Copilot AI and others added 2 commits April 21, 2026 20:33
Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/53219443-a721-4e6d-a7c3-21a6387b3396

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/53219443-a721-4e6d-a7c3-21a6387b3396

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix performance issue with apply qe in BV formula Improve qe-light elimination for BV vars constrained by constant (dis)equalities Apr 21, 2026
Copilot AI requested a review from NikolajBjorner April 21, 2026 20:38
if (!bv.is_bv_sort(var_sort))
return false;
obj_hashtable<expr> values;
if (!collect_bv_eq_constants(body, i, values) || values.empty())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fails fast instead of handling bit-vector variables that satisfy the conditions

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.

apply qe on a small BV formula does not produce output within 60s

2 participants