I am trying to use Z3 .net API to get an existence quantifier expr. Following are my code:

RealExpr c = ctx.MkRealConst("c");
BoolExpr Eqzero = ctx.MkGt(c,ctx.MkReal(0));    
BoolExpr Gezero = ctx.MkGe(c,ctx.MkReal(0));
BoolExpr Lttwo = ctx.MkLt(c,ctx.MkReal(2));
BoolExpr Gtthree = ctx.MkGt(c,ctx.MkReal(3)); 

BoolExpr b1 = ctx.MkBoolConst("b1");
BoolExpr b2 = ctx.MkBoolConst("b2");
BoolExpr b3 = ctx.MkBoolConst("b3");
BoolExpr b0 = ctx.MkBoolConst("b0");   

RealExpr[] lamb=new RealExpr[1];

lamb[0]=ctx.MkRealConst("lamb");

BoolExpr temp=ctx.MkAnd(
     ctx.MkGt(lamb[0],ctx.MkReal(0)),
     ctx.MkEq(b0,ctx.MkTrue()),
     ctx.MkEq(b1,ctx.MkTrue()),
     ctx.MkGe(ctx.MkAdd(c,lamb[0]),ctx.MkReal(0)),
     ctx.MkLe(ctx.MkAdd(c,lamb[0]),ctx.MkReal(3)),
     ctx.MkGe(c,ctx.MkReal(0)),
     ctx.MkLe(c,ctx.MkReal(3))
                    );   


BoolExpr exist = ctx.MkExists(lamb, temp, 1, null, null, ctx.MkSymbol("Q2"),            ctx.MkSymbol("skid2"));

Console.WriteLine(exist.ToString());
Solver s1 = ctx.MkSolver();
s1.Assert(exist);
if (s1.Check() == Status.SATISFIABLE)
{
  Console.WriteLine("get pre");
  Console.Write(s1);
}
else
{
   Console.WriteLine("Not reach");
}
Console.ReadKey();

'

For the program, I got the following result:

(exists ((lamb Real))
 (! (and (> lamb 0.0)
      (= b0 true)
      (= b1 true)
      (>= (+ c lamb) 0.0)
      (<= (+ c lamb) 3.0)
      (>= c 0.0)
      (<= c 3.0))
 :skid skid2
 :qid Q2))
 Not reach

My questions are 1. What is the meaning of the ! in the result/ 2. What is the reason that I cannot get sat result? 3. Could someone offer some martial corresponding to the Z3 .NET API besides the API menu on the Z3 website.

Thanks very much!

有帮助吗?

解决方案

The meaning of the (! ...) function is an annotation that binds patterns and quantifier and Skolem IDs to the expression. When this line

BoolExpr exist = ctx.MkExists(lamb, temp, 1, null, null, ctx.MkSymbol("Q2"), ctx.MkSymbol("skid2"));

is changed to

BoolExpr exist = ctx.MkExists(lamb, temp, 1);

then there is no (! ...) in the output.

I can't replicate the UNSAT result: When I run this example using Z3 4.0, I get SAT and the following model:

(define-fun lamb!0 () Real  1.0)
(define-fun c () Real  1.0)
(define-fun b1 () Bool true)
(define-fun b0 () Bool true)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top