Z3 推理XOR(所有AC理论?)

Z3 推理XOR(所有AC理论?),z3,Z3,似乎关于XOR的推理导致Z3的内存使用爆炸性增长(提交210BCA8F456361F696152BE909E33A4 E8B58607F2)。例如,从与a+b+c+x+x+y+y+z等价的事物派生出a+b+c: (declare-fun known (Bool) Bool) (declare-fun p (Bool Bool Bool) Bool) ; Lift xor (assert (forall ((x Bool) (y Bool)) (=> (and (k

似乎关于XOR的推理导致Z3的内存使用爆炸性增长(提交210BCA8F456361F696152BE909E33A4 E8B58607F2)。例如,从与a+b+c+x+x+y+y+z等价的事物派生出
a+b+c

(declare-fun known (Bool) Bool)
(declare-fun p (Bool Bool Bool) Bool)

; Lift xor
(assert (forall ((x Bool) (y Bool))
            (=> (and (known x) (known y)) (known (xor x y)))))

; Can reason about xor well
(assert (exists ((a1 Bool) (b1 Bool) (c1 Bool) (ra Bool) (rb Bool) (rc Bool))
            (and (p a1 b1 c1)
                 (known (xor a1 (xor ra rc)))
                 (known (xor b1 (xor rb ra)))
                 (known (xor c1 (xor rc rb))))))

; Assert that we can derive a+b+c.
; Note: The behavior (non-termination) is the same when this example is
;       inverted (forall ... not ...)
(assert (exists ((a1 Bool) (b1 Bool) (c1 Bool))
            (and (p a1 b1 c1)
                 (known (xor a1 (xor b1 c1))))))
(check-sat)
这是公认的限制吗?我可以用Z3回答类似这样的问题吗


连续性:我有这个任务的HORN逻辑。

问题是断言

(assert (forall ((x Bool) (y Bool))
            (=> (and (known x) (known y)) (known (xor x y)))))
这对电子匹配引擎来说真的很糟糕。这是Z3中用于处理量词的引擎之一。 有许多可能的解决办法

1) 使用量词消去法。您只需将
(检查sat)
替换为
(使用(然后是qe smt)检查sat)

2) 用
:weight
属性注释量词。电子匹配引擎将提前停止生成新实例。以下是一个例子:

(assert (forall ((x Bool) (y Bool))
        (!  (=> (and (known x) (known y)) (known (xor x y)))
            :weight 10)))
3) 禁用电子匹配引擎。然后,Z3将只使用MBQI(基于模型的量词实例化)引擎,这对于此类问题更有效。要禁用电子匹配,我们应该使用

(set-option :smt.ematching false)
备注:在Z3版本中