how to get multiple solutions for z3 solver in smt2 format example?

后端 未结 1 1646
逝去的感伤
逝去的感伤 2021-01-28 16:37

How to generate multiple models for bit vector formula using z3 solver in smt2 format?

While implementing IDEA Code for Bit Vector it is generating one model.

Ho

相关标签:
1条回答
  • 2021-01-28 17:27

    The usual approach is to add a new constraint that excludes the first model. In this example, this would look like so:

    (check-sat)
    
    (assert (and (not (= k16 #x2c7d))  (not (= ... ))
    (check-sat)
    

    There is no SMT2 command to get all solutions or the number of solutions. If something depends on the fact that some property holds for all solutions, we can encode that using quantifiers, e.g.

    (assert (forall ((x (_ BitVec 16))) (... property depending on x ...))) 
    

    However, those types of problems are of course harder to solve and Z3 will use different decision procedures under the hood.

    0 讨论(0)
提交回复
热议问题