在表达式中调用函数。 Z3

时间:2014-07-30 09:21:44

标签: java z3

我想表达

(assert(forall((t Task)) (not (mustPrecede t t))))    

使用java API跟随JavaExample.java中的示例,如下所示

FuncDecl must =  ctx.mkFuncDecl("mustPrecede", new Sort[]{TASK,TASK},ctx.mkBoolSort());                        
Expr Task1 = ctx.mkConst("TAKS1",TASK);
Expr[] bounds = new Expr[] { Task1 };        
Expr bodys = ctx.mkNot(must[bounds[1],bounds[1]]);

q1 = ctx.mkForall(bounds, bodys, 1, null, no_pats, ctx.mkSymbol("q"),ctx.mkSymbol("sk"));

但是这行给了我一个错误..这是调用函数内部和表达式的正确方法吗?你能帮助我一个简单的例子来说明如何为所有人表达上述内容,在可用的例子中没有类似的东西。非常感谢!

Expr bodys = ctx.mkNot(must[bounds[1],bounds[1]]);

1 个答案:

答案 0 :(得分:1)

我设法按如下方式进行

//function declaration
FuncDecl assignUser = ctx.mkFuncDecl("assignUser", Task, User);
FuncDecl TaskUser = ctx.mkFuncDecl("TaskUser", new Sort[] { Task, User }, ctx.mkBoolSort());
FuncDecl mustPrecede = ctx.mkFuncDecl("mustPrecede", new Sort[]{Task,Task}, ctx.mkBoolSort());

//task for using in quatifiers
Expr task = ctx.mkConst("t", ctx.mkUninterpretedSort(ctx.mkSymbol("Task")));

// creating (assert(forall((t Task)) (not (mustPrecede t t))))
//just one task is needed
Sort[] Tasks = new Sort[1];
Tasks[0] =ctx.mkUninterpretedSort(ctx.mkSymbol("Task"));
//setting the name for the task
Symbol[] namess = new Symbol[1];
namess[0] =  ctx.mkSymbol("t");
//Creating a map between mustPrecede and  its two parameters
Expr mtt = ctx.mkApp(mustPrecede, task,task);
//acreating not
Expr body = ctx.mkNot((BoolExpr)mtt);

Expr mustPrecedett = ctx.mkForall(Tasks, namess, body, 1, null, null,
ctx.mkSymbol("Q1"), ctx.mkSymbol("skid1"));

System.out.println("Quantifier mustPrecedett: " + mustPrecedett.toString());