Cheatsheet
January 24, 2023 ยท View on GitHub
BitVec
- A vector of bits
- Has no initial value
- A
BitVecof8 bits=1 byte
BitVecVal
- A
BitVecwith initial value
ZeroExt / SignExt
- A way to convert between different Z3 data types
ZeroExtextends withtrailing0sSignExtextends withleading0sZeroExt(24, foo)-> extends an8-bitbytefooto a32-bitint
Solver
- The theorem solver
- Constrains are added using
Solver.add(...)
Arithmetic logic
-
When performing operations on Z3 data types, Z3 will use the
expressionrather than computing the values:foo = BitVecVal(0, 8) bar = [BitVec(f"bar_{i}", 8) for i in range(0, 3)] for i in range(0, 3): foo += bar[i] # result actual value of foo: # (foo + bar[0] + bar[1] + bar[2])