Is it possible to cast a bitvector of one bit into a boolean variable in SMTLib2?

后端 未结 2 1745
深忆病人
深忆病人 2021-01-20 12:40

I want to have a boolean variable that test if, e.g., the third bit of a bit vector is 0. The theory of bitvector allows to extract 1 bit as a bitvector, but not a boolean t

相关标签:
2条回答
  • 2021-01-20 13:31

    What you are doing is just fine; it's just that bit0 is a reserved name. Just call it something else. (mybit0 would work, or some other unreserved name.)

    0 讨论(0)
  • 2021-01-20 13:39

    Create an equality between the extraction of the third bit and a bit-vector with value 1 (and one bit).

    E.g,

    (declare-const x (_ BitVec 5))
    (assert (= #b1 ((_ extract 2 2) x)))
    (check-sat)
    (get-model)
    

    produces

    sat
    (model
      (define-fun x () (_ BitVec 5)
        #b00100)
    )
    
    0 讨论(0)
提交回复
热议问题