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

Method modelConverterTest

examples/java/JavaExample.java:315–349  ·  view source on GitHub ↗
(Context ctx)

Source from the content-addressed store, hash-verified

313 }
314
315 void modelConverterTest(Context ctx) throws TestFailedException
316 {
317 System.out.println("ModelConverterTest");
318
319 ArithExpr xr = (ArithExpr) ctx.mkConst(ctx.mkSymbol("x"),
320 ctx.mkRealSort());
321 ArithExpr yr = (ArithExpr) ctx.mkConst(ctx.mkSymbol("y"),
322 ctx.mkRealSort());
323 Goal g4 = ctx.mkGoal(true, false, false);
324 g4.add(ctx.mkGt(xr, ctx.mkReal(10, 1)));
325 g4.add(ctx.mkEq(yr, ctx.mkAdd(xr, ctx.mkReal(1, 1))));
326 g4.add(ctx.mkGt(yr, ctx.mkReal(1, 1)));
327
328 ApplyResult ar = applyTactic(ctx, ctx.mkTactic("simplify"), g4);
329 if (ar.getNumSubgoals() == 1
330 && (ar.getSubgoals()[0].isDecidedSat() || ar.getSubgoals()[0]
331 .isDecidedUnsat()))
332 throw new TestFailedException();
333
334 ar = applyTactic(ctx, ctx.andThen(ctx.mkTactic("simplify"),
335 ctx.mkTactic("solve-eqs")), g4);
336 if (ar.getNumSubgoals() == 1
337 && (ar.getSubgoals()[0].isDecidedSat() || ar.getSubgoals()[0]
338 .isDecidedUnsat()))
339 throw new TestFailedException();
340
341 Solver s = ctx.mkSolver();
342 for (BoolExpr e : ar.getSubgoals()[0].getFormulas())
343 s.add(e);
344 Status q = s.check();
345 System.out.println("Solver says: " + q);
346 System.out.println("Model: \n" + s.getModel());
347 if (q != Status.SATISFIABLE)
348 throw new TestFailedException();
349 }
350
351 // / A simple array example.
352

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