mirror of
https://github.com/Z3Prover/z3
synced 2025-04-25 10:05:32 +00:00
Bugfix and new examples for implicit assumptions in Z3_solver_assert_and_track. Thanks to Amir Ebrahimi for reporting this issue!
(See http://stackoverflow.com/questions/28558683/modeling-constraints-in-z3-and-unsat-core-cases) Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
parent
d3fb5f2a4c
commit
9b137d54d3
5 changed files with 111 additions and 3 deletions
|
@ -2137,6 +2137,47 @@ class JavaExample
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract unsatisfiable core example with AssertAndTrack
|
||||
|
||||
public void unsatCoreAndProofExample2(Context ctx) throws Z3Exception
|
||||
{
|
||||
System.out.println("UnsatCoreAndProofExample2");
|
||||
Log.append("UnsatCoreAndProofExample2");
|
||||
|
||||
Solver solver = ctx.mkSolver();
|
||||
|
||||
BoolExpr pa = ctx.mkBoolConst("PredA");
|
||||
BoolExpr pb = ctx.mkBoolConst("PredB");
|
||||
BoolExpr pc = ctx.mkBoolConst("PredC");
|
||||
BoolExpr pd = ctx.mkBoolConst("PredD");
|
||||
|
||||
BoolExpr f1 = ctx.mkAnd(new BoolExpr[] { pa, pb, pc });
|
||||
BoolExpr f2 = ctx.mkAnd(new BoolExpr[] { pa, ctx.mkNot(pb), pc });
|
||||
BoolExpr f3 = ctx.mkOr(ctx.mkNot(pa), ctx.mkNot(pc));
|
||||
BoolExpr f4 = pd;
|
||||
|
||||
BoolExpr p1 = ctx.mkBoolConst("P1");
|
||||
BoolExpr p2 = ctx.mkBoolConst("P2");
|
||||
BoolExpr p3 = ctx.mkBoolConst("P3");
|
||||
BoolExpr p4 = ctx.mkBoolConst("P4");
|
||||
|
||||
solver.assertAndTrack(f1, p1);
|
||||
solver.assertAndTrack(f2, p2);
|
||||
solver.assertAndTrack(f3, p3);
|
||||
solver.assertAndTrack(f4, p4);
|
||||
Status result = solver.check();
|
||||
|
||||
if (result == Status.UNSATISFIABLE)
|
||||
{
|
||||
System.out.println("unsat");
|
||||
System.out.println("core: ");
|
||||
for (Expr c : solver.getUnsatCore())
|
||||
{
|
||||
System.out.println(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void finiteDomainExample(Context ctx) throws Z3Exception
|
||||
{
|
||||
|
@ -2298,6 +2339,7 @@ class JavaExample
|
|||
p.treeExample(ctx);
|
||||
p.forestExample(ctx);
|
||||
p.unsatCoreAndProofExample(ctx);
|
||||
p.unsatCoreAndProofExample2(ctx);
|
||||
}
|
||||
|
||||
{ // These examples need proof generation turned on and auto-config
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue