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

Method modelConverterTest

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

Source from the content-addressed store, hash-verified

299 }
300
301 @SuppressWarnings("unchecked")
302 void modelConverterTest(Context ctx) throws TestFailedException
303 {
304 System.out.println("ModelConverterTest");
305
306 Expr<RealSort> xr = ctx.mkConst(ctx.mkSymbol("x"), ctx.mkRealSort());
307 Expr<RealSort> yr = ctx.mkConst(ctx.mkSymbol("y"), ctx.mkRealSort());
308 Goal g4 = ctx.mkGoal(true, false, false);
309 g4.add(ctx.mkGt(xr, ctx.mkReal(10, 1)));
310 g4.add(ctx.mkEq(yr, ctx.mkAdd(xr, ctx.mkReal(1, 1))));
311 g4.add(ctx.mkGt(yr, ctx.mkReal(1, 1)));
312
313 ApplyResult ar = applyTactic(ctx, ctx.mkTactic("simplify"), g4);
314 if (ar.getNumSubgoals() == 1
315 && (ar.getSubgoals()[0].isDecidedSat() || ar.getSubgoals()[0]
316 .isDecidedUnsat()))
317 throw new TestFailedException();
318
319 ar = applyTactic(ctx, ctx.andThen(ctx.mkTactic("simplify"),
320 ctx.mkTactic("solve-eqs")), g4);
321 if (ar.getNumSubgoals() == 1
322 && (ar.getSubgoals()[0].isDecidedSat() || ar.getSubgoals()[0]
323 .isDecidedUnsat()))
324 throw new TestFailedException();
325
326 Solver s = ctx.mkSolver();
327 for (BoolExpr e : ar.getSubgoals()[0].getFormulas())
328 s.add(e);
329 Status q = s.check();
330 System.out.printf("Solver says: %s%n", q);
331 System.out.printf("Model: %n%s%n", s.getModel());
332 if (q != Status.SATISFIABLE)
333 throw new TestFailedException();
334 }
335
336 // / A simple array example.
337

Callers 1

basicTestsMethod · 0.95

Calls 15

addMethod · 0.95
applyTacticMethod · 0.95
getNumSubgoalsMethod · 0.95
getSubgoalsMethod · 0.95
addMethod · 0.95
checkMethod · 0.95
getModelMethod · 0.95
mkConstMethod · 0.80
mkSymbolMethod · 0.80
mkRealSortMethod · 0.80
mkGoalMethod · 0.80
mkGtMethod · 0.80

Tested by

no test coverage detected