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

后端 未结 2 1753
深忆病人
深忆病人 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: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)
    )
    

提交回复
热议问题