Z3 complains that assumption is not a propositional variable, even when it actually is

本小妞迷上赌 提交于 2020-01-17 02:41:07

问题


I'm using the Java API. This is a minimal working example for this warning:

HashMap<String, String> cfg = new HashMap<String, String>();
cfg.put("model", "true");
Context ctx = new Context(cfg);
Solver solver = ctx.mkSolver();
BoolExpr a = ctx.mkBoolConst("a");
BoolExpr b = ctx.mkBoolConst("b");
BoolExpr and = ctx.mkAnd(a,b); 
solver.check(and);

For this small program, Z3 complained that:

WARNING: an assumption must be a propositional variable or the negation of one

Unless I misunderstood something, and is a propositional variable, so I do not understand why there is this warning. Moreover, the check method takes an array of BoolExpr as parameters, so why it requires a propositional variable?

My question: can I safely ignore this warning?


回答1:


No, and is not a propositional variable, but it's a propositional term (or in other words a BoolExpr). Assumption literals for solver.check(...) need to be variables or the negation of a variable, i.e., a or not a, but not a and b.

This warning is not safe to ignore, because it means that Z3 will ignore those assumptions, i.e., you may get unexpected results.

Just to avoid confusion: the arguments to solver.check(...) are assumption literals, they are not assertions, i.e., if we want to check whether and is satisfiable we need to first assert it and then ask the solver to check without further assumptions, e.g.,

...
solver.assert(and);
solver.check();


来源:https://stackoverflow.com/questions/38883493/z3-complains-that-assumption-is-not-a-propositional-variable-even-when-it-actua

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!