I am using Z3 for Java to check satisfiability on terms with uninterpreted functions such as (type(o)>1 or type(p)<1). I am running into a performance issue caused by the check() function. For instance, it takes 6 ms to run solver.check() for a very simple constraint(type(o)>2 and type(o)=1).
FuncDecl typeFun = ctx.MkFuncDecl("type", ctx.IntSort(), ctx.IntSort());
Expr o = ctx.MkConst("o", ctx.IntSort());
//type(o)
IntExpr to = (IntExpr)typeFun.Apply(o);
//type(o)=1
BoolExpr subExpr1 = ctx.MkEq(to, ctx.MkInt("1"));
//type(o)>2
BoolExpr subExpr2 = ctx.MkGt(to, ctx.MkInt("2"));
//type(o)>2 and type(o)=1
BoolExpr expr = ctx.MkAnd(new BoolExpr[] { subExpr1, subExpr2 });
solver.Assert(expr);
//this step will take 6 ms.
solver.check();
Given that the size of actual constraints in my project is much bigger(But each term is very simple such as type(o1)=1, type(o2)>1, etc) than this example and there are billions of such constraint need to resolve:
1. Is the performance of check() supposed to be like this?
2. If the answer to 1 is Yes, is there any other alternative way to bypass the performance issue?
Thanks in advance.
@ChristophWintersteiger: I think a large portion of constraints in my system should be SAT. I am implementing a pointer analysis for Java and I am using Z3 to resolve the potential targets of virtual calls in a bottom-up way. Suppose I have a virtual callsite v.foo() and this callsite may invoke different methods based on the dynamic type of v. So for each callee foo(), I will introduce a constraint type(o) = T where o is the points-to set of receiver v and T is the class that declares foo. The constraint means that v.foo() can invoke method foo() in T when one of its dynamic points-to set has a type of T. All the constraint in my current system is some linear arithmetic with only one uninterpreted function "type(o)". But since I am analyzing the callgraph in a bottom-up manner, the constraint related to each virtual callsite can be expanded util the analysis reaches the root level and all the points-to targets of receivers have been resolved.