1

I am trying to express

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

With the java API following the examples in JavaExample.java as follows

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"));

but this line gives me an error.. is this the correct way of calling a function inside and expression??. Can you help me with one simple example of how to express the above for all, in the available examples there is nothing similar. Thanks a lot!

Expr bodys = ctx.mkNot(must[bounds[1],bounds[1]]);
Christoph Wintersteiger
  • 8,234
  • 1
  • 16
  • 30
user3723800
  • 145
  • 7

1 Answers1

1

I manage to do it as follows

//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());
user3723800
  • 145
  • 7
  • That looks like a good solution. The following is essentially a one-line way to do the same: Expr bodys = ctx.mkNot((BoolExpr) must.apply(new Expr[] {bounds[0],bounds[0]})); – Christoph Wintersteiger Jul 30 '14 at 13:15