My task is:
input 10023678 (as a decimal number)
output 10023678 (as a hex number:)
I have solved this using the SMT-LIB formula in the bit-vector logic. But I would love to know how can I do it in python using the "import z3"
.smt2 INPUT CODE:
(set-logic QF_BV)
(set-option :produce-models true)
(declare-fun x () (_ BitVec 32))
(assert (= ((_ extract 3 3) x) ((_ extract 3 3 ) (bvnot(bvxor x x)))))
(assert (= ((_ extract 4 4) x) ((_ extract 4 4) (bvnot(bvxor x x)))))
(assert (= ((_ extract 5 5) x) ((_ extract 5 5) (bvnot(bvxor x x)))))
(assert (= ((_ extract 6 6) x) ((_ extract 6 6) (bvnot(bvxor x x)))))
(assert (= ((_ extract 9 9) x) ((_ extract 9 9) (bvnot(bvxor x x)))))
(assert (= ((_ extract 10 10) x) ((_ extract 10 10) (bvnot(bvxor x x)))))
(assert (= ((_ extract 12 12) x) ((_ extract 12 12) (bvnot(bvxor x x)))))
(assert (= ((_ extract 13 13) x) ((_ extract 13 13) (bvnot(bvxor x x)))))
(assert (= ((_ extract 17 17) x) ((_ extract 17 17) (bvnot(bvxor x x)))))
(assert (= ((_ extract 28 28) x) ((_ extract 28 28) (bvnot(bvxor x x)))))
(check-sat)
(get-model)
(exit)
OUTPUT:
sat
(
(define-fun x () (_ BitVec 32)
#x10023678)
)