【发布时间】:2015-02-17 09:33:02
【问题描述】:
我正在使用 Z3 求解器并在 C# 中实现。我在他们的 .Net API (http://z3.codeplex.com/SourceControl/latest#examples/dotnet/Program.cs) 描述中使用了 Microsoft 给出的示例。在此示例中,我尝试将函数“UnsatCoreAndProofExample”中的模型替换为我自己的模型:
Expr x = ctx.MkConst("x", ctx.MkIntSort());
Expr y = ctx.MkConst("y", ctx.MkIntSort());
Expr zero = ctx.MkNumeral(0, ctx.MkIntSort());
Expr one = ctx.MkNumeral(1, ctx.MkIntSort());
Expr five = ctx.MkNumeral(5, ctx.MkIntSort());
BoolExpr constraint1 = ctx.MkBoolConst("Constraint1");
solver.AssertAndTrack(ctx.MkGt((ArithExpr)x, (ArithExpr)zero), constraint1);
BoolExpr constraint2 = ctx.MkBoolConst("Constraint2");
solver.AssertAndTrack(ctx.MkEq((ArithExpr)y, ctx.MkAdd((ArithExpr)x, (ArithExpr)one)), constraint2);
BoolExpr constraint3 = ctx.MkBoolConst("Constraint3");
solver.AssertAndTrack(ctx.MkLt((ArithExpr)y, (ArithExpr)five), constraint3);
BoolExpr constraint4 = ctx.MkBoolConst("Constraint4");
solver.AssertAndTrack(ctx.MkLt((ArithExpr)x, (ArithExpr)zero), constraint4);
Status result = solver.Check();
我期望的结果是在 Unsat 代码中返回 Constraint1 和 Constraint4。我知道返回 Unsatcore 的设置是正确的,因为当我运行原始的“UnsatCoreAndProofExample”函数时,会返回 unsat Core。但是当我只是将模型更改为上面的模型时,虽然结果是 Unsat 但没有返回 Unsatcore。 所以我的问题是,可能是因为我编写模型的方式,还是我犯了另一个错误?
【问题讨论】:
-
这看起来好像有一个错误,我们正在努力。