MCPcopy Create free account
hub / github.com/Z3Prover/z3 / bitvectorExample2

Method bitvectorExample2

examples/java/JavaGenericExample.java:1204–1224  ·  view source on GitHub ↗
(Context ctx)

Source from the content-addressed store, hash-verified

1202 // / Find x and y such that: x ^ y - 103 == x * y
1203
1204 public void bitvectorExample2(Context ctx) throws TestFailedException
1205 {
1206 System.out.println("BitvectorExample2");
1207 Log.append("BitvectorExample2");
1208
1209 /* construct x ^ y - 103 == x * y */
1210 BitVecSort bv_type = ctx.mkBitVecSort(32);
1211 BitVecExpr x = ctx.mkBVConst("x", 32);
1212 BitVecExpr y = ctx.mkBVConst("y", 32);
1213 BitVecExpr x_xor_y = ctx.mkBVXOR(x, y);
1214 Expr<BitVecSort> c103 = ctx.mkNumeral("103", bv_type);
1215 BitVecExpr lhs = ctx.mkBVSub(x_xor_y, c103);
1216 BitVecExpr rhs = ctx.mkBVMul(x, y);
1217 BoolExpr ctr = ctx.mkEq(lhs, rhs);
1218
1219 System.out.println("find values of x and y, such that x ^ y - 103 == x * y");
1220
1221 /* find a model (i.e., values for x an y that satisfy the constraint */
1222 Model m = check(ctx, ctr, Status.SATISFIABLE);
1223 System.out.println(m);
1224 }
1225
1226 // / Demonstrates how to use the SMTLIB parser.
1227

Callers 1

mainMethod · 0.95

Calls 9

appendMethod · 0.95
checkMethod · 0.95
mkBitVecSortMethod · 0.80
mkBVConstMethod · 0.80
mkBVXORMethod · 0.80
mkNumeralMethod · 0.80
mkBVSubMethod · 0.80
mkBVMulMethod · 0.80
mkEqMethod · 0.80

Tested by

no test coverage detected