Skip to content

Instability due to maximizing-bv-sharing pass #11848

In progress

Description

Like #11847 this is from an autoformalization effort. It appears to be improved by a patch and has a reproduction file, but I can't vouch for much more than that. If such an issue is unwelcome, please let me know or feel free to close of course.


maximize_ac_sharing::reduce_app checks f->is_associative() and whether f->get_kind() is one of the registered BV kinds, but never the family id. The kinds collide:

BV kind value basic arith
OP_BADD 4 OP_ITE OP_LT
OP_BMUL 6 OP_OR OP_ADD

Before #11737 (1d1e753) init() was never called from reduce_app, so the pass was a no-op. Now the SMT kernel's maximizing-bv-sharing step (on by default, no user parameter) rebalances every or and arith + with 3 or more arguments into a binary tree, in every query. A breakpoint on maximize_ac_sharing::insert fires on or (family 0) for a query with no bit-vectors.

Visible effect: a small quantified EUF benchmark [see zf_prod_zero_ext.smt2 below] goes from 0/14 to 6/14 seeds timing out (3 s), bisected to 1d1e753.

Fix: only rewrite applications of the BV family: philzook58@9620d7650

More context (seed tables across versions, bisect log, effect on another benchmark): philzook58/knuckledragger#107 (comment)

; benchmark generated from python API
(set-info :status unknown)
(declare-sort ZFSet 0)
(declare-fun |∈| (ZFSet ZFSet) Bool)
(declare-fun pair (ZFSet ZFSet) ZFSet)
(declare-fun psnd (ZFSet) ZFSet)
(declare-fun pfst (ZFSet) ZFSet)
(declare-fun prod (ZFSet ZFSet) ZFSet)
(declare-fun |∅| () ZFSet)
(declare-fun zf.zero () ZFSet)
(assert
 (forall ((A ZFSet) (B ZFSet) )(let (($x234 (forall ((x ZFSet) )(let (($x152 (|∈| x B)))
 (let (($x178 (|∈| x A)))
 (= $x178 $x152))))
 ))
 (let (($x245 (= A B)))
 (= $x245 $x234))))
 )
(assert
 (forall ((A ZFSet) (B ZFSet) (p ZFSet) )(let ((?x2685 (pfst p)))
 (let (($x9617 (|∈| ?x2685 A)))
 (let ((?x2451 (prod A B)))
 (let (($x876 (|∈| p ?x2451)))
 (= $x876 (and $x9617 (|∈| (psnd p) B) (= p (pair ?x2685 (psnd p))))))))))
 )
(assert
 (forall ((x ZFSet) )(let (($x250 (|∈| x |∅|)))
 (= $x250 false)))
 )
(assert
 (= zf.zero |∅|))
(assert
 (let (($x14137 (forall ((A ZFSet) )(= (prod A zf.zero) |∅|))
))
(not $x14137)))
(check-sat)

To reproduce (3 s timeout, seeds 0–13):

for s in $(seq 0 13); do z3 -T:3 smt.random_seed=$s zf_prod_zero_ext.smt2; done

On 1d1e753 and master, seeds 0, 4, 6, 7, 11 and 13 time out; on its parent 5e70128 all 14 are unsat. With the family-id fix, all 14 are unsat again.

Activity

  1. NikolajBjorner commented on Nov 25, 2026

    @NikolajBjorner
    Contributor

    why would it be unwelcome? Mainly scrambling to keep pace, but this doesn't negate having visibility into facts.

  2. philzook58 commented on Nov 25, 2026

    @philzook58
    ContributorAuthor

    I don't know. I'm not sure how I would feel if I were on the other end. I know bulk fuzzing issues and AI generated issues can be more predatory than helpful depending on how they are done. I also don't have the attention span to truly understand the issue, which seems hypocritical.
    But glad it may be useful. Big Z3 fan.

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions