Z3: Offering random solutions in solving

前端 未结 1 1846
时光取名叫无心
时光取名叫无心 2021-01-05 01:56

I tried the following code in http://rise4fun.com/z3/tutorial

(declare-const a Int)
(assert (> a 100))
(check-sat)
(get-model)
相关标签:
1条回答
  • 2021-01-05 02:35

    The linear arithmetic solver is based on the Simplex algorithm. So, the solutions will not be random. The bit-vector solver is based on SAT, you can get "random" solutions by encoding your problem in bit-vector arithmetic and selecting random phase selection. Here is an example (also available here):

    (set-option :auto-config false)
    (set-option :phase-selection 5) ;; select random phase selection
    (declare-const a (_ BitVec 32))
    (assert (bvugt a (_ bv100 32))) ;; a > 100 as a bitvector constraint
    (check-sat)
    (get-model)
    ;; try again
    (check-sat)
    (get-model)
    ;; try again
    (check-sat)
    (get-model)
    
    0 讨论(0)
提交回复
热议问题