Z3 String/char Xor?
I'm working with Z3 in Python and am trying to figure out how to do String operations. In general, I've played around with z3.String as the object, doing things like str1 + str2 ==
Solution 1:
So far I don't expose ways to access characters with a function. You would have to define auxiliary functions and axioms that capture extraction. The operator [] extracts a sub-sequence, which is of length 1 if the index is within bounds.
Here is a way to access the elements:
from z3 import *
nth = Function('nth', StringSort(), IntSort(), BitVecSort(8))
k = Int('k')
str1, str2, s = Strings('str1 str2 s')
s = Solver()
s.add(ForAll([str1, k], Implies(And(0 <= k, k < Length(str1)), Unit(nth(str1, k)) == str1[k])))
s.add( ((nth(str1, 1)) ^ (nth(str2, 2))) == 12)
Post a Comment for "Z3 String/char Xor?"