简体   繁体   English

z3行为根据不满核心的要求而变化

[英]z3 behaviour changing on request for unsat core

I have several SMTLIB2 examples which z3 normally finds unsat in 10s of milliseconds, yet, when I add in a request for it to generate unsat cores, the check-sat keeps going for minutes without returning. 我有几个SMTLIB2示例,z3通常在10毫秒内找不到,但是,当我添加请求生成不满核心时,check-sat会持续几分钟而不返回。 Is this behaviour to be expected? 这种行为是期待的吗? Does requesting unsat cores do more than just switch on instrumentation recording dependencies, and change which procedures and options z3 runs with? 请求不良核心不只是打开仪器记录依赖关系,并更改z3运行的程序和选项吗? Is it possible to set further options so I see the same behaviour when I'm using unsat core generation as I see when I'm not using it? 是否有可能设置更多选项,所以当我使用不满核心生成时,我看到相同的行为,因为我看到我不使用它时?

I'm using Z3 4.3.1 (stable branch) on Scientific Linux 6.3. 我在Scientific Linux 6.3上使用Z3 4.3.1(稳定分支)。

The examples are in AUFNIRA, though several involve no reals and probably are not non-linear. 这些例子在AUFNIRA中,虽然有几个没有实际,也可能不是非线性的。

Thanks, 谢谢,

Paul. 保罗。

The unsat cores are tracked using "answer literals" (aka assumptions). 使用“答案文字”(又称假设)跟踪不满核心。 When we enable unsat core extraction and use assertions such as 当我们启用不饱和核心提取并使用断言如

(assert  (! (= x 10) :named a1))

Z3 will internally create a fresh Boolean variable for the name a1 , and assert Z3将在内部为名称a1创建一个新的布尔变量,并断言

(assert  (=> a1 (= x 10)))

When, check-sat is invoked, it assumes all these auxiliary variables are true. 当调用check-sat ,它假定所有这些辅助变量都为真。 That is, Z3 tries to show the problem is unsat/sat modulo these assumptions. 也就是说,Z3试图表明这些假设是不满足的。 For satisfiable instances, it will terminate as usual with a model. 对于可满足的实例,它将像通常一样使用模型终止。 For unsatisfiable instances, it will terminate whenever it generates a lemma that contains only these assumed Boolean variables. 对于不可满足的实例,只要它生成仅包含这些假设的布尔变量的引理,它就会终止。 The lemma is of the form (or (not a_i1) ... (not a_in)) where the a_i 's are a subset of the assumed Boolean variables. 引理的形式(or (not a_i1) ... (not a_in))其中a_i是假定的布尔变量的子集。 As far as I know, this technique has been introduced by the MiniSAT solver. 据我所知,这项技术已经由MiniSAT求解器引入。 It is described here (Section 3). 这里描述(第3节)。 I really like it because it is simple to implement and we essentially get unsat core generation for free. 我非常喜欢它,因为它实现起来很简单,而且我们基本上可以免费获得核心代。

However, this approach has some disadvantages. 但是,这种方法有一些缺点。 First, some preprocessing steps are not applicable anymore. 首先,一些预处理步骤不再适用。 If we just assert 如果我们断言

(assert (= x 10))

Z3 will replace x with 10 everywhere. Z3将替换x替换为10处。 We say Z3 is performing "value propagation". 我们说Z3正在进行“价值传播”。 This preprocessing step is not applied if the assertion is of the form 如果断言是表单,则不应用此预处理步骤

(assert  (=> a1 (= x 10)))

This is just an example, many other preprocessing steps are affected. 这只是一个例子,许多其他预处理步骤都会受到影响。 During solving time, some of the simplification steps are also disabled. 在求解期间,一些简化步骤也被禁用。 If we inspect the Z3 source file smt_context.cpp we will find code such as: 如果我们检查Z3源文件smt_context.cpp,我们将找到如下代码:

   void context::simplify_clauses() {
        // Remark: when assumptions are used m_scope_lvl >= m_search_lvl > m_base_lvl. Therefore, no simplification is performed.
        if (m_scope_lvl > m_base_lvl)
            return;
        ...
   }

The condition m_scope_lvl > m_base_lvl) is always true when "answer literals"/assumptions are used. 当使用“回答文字”/假设时,条件m_scope_lvl > m_base_lvl)始终为true。 So, when we enable unsat core generation, we may really impact the performance. 因此,当我们启用不良核心生成时,我们可能会真正影响性能。 It seems that nothing is really for free :) 似乎没有什么是免费的:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM