在z3中编码伪布尔约束最有效的方法是什么?
我认为这里有两个不同的相关案例: 案例1: 我有一组布尔变量,我想要另一个布尔变量,如果这些变量中的任何一个是真的,那么这个布尔变量就是真的。 我目前正在通过使布尔变量成为整数来实现这一点,然后使用以下形式的表达式进行设置: (ite(布尔表达式)1 0) 然后,我使用一个和和和一个大于 (>(+b1 b2 b3…)0) 案例2(这可能不是真正的伪布尔): 我有两组布尔变量: set1=n_1,n_2 set2=m_1,m_2 我想添加一个约束,即set1中设置为true的变量数等于set2中设置为true的变量数 如上所述,我目前正在通过使用整数而不是布尔数来实现这一点,并使用如下形式的ite设置每个整数: n_1=(ite(boolean_expr)1 0) 然后说: n_1+n_2+…=m_1+m_2 在每种情况下,使用整数变量是最有效的方法,还是有更好的方法在z3中编码伪布尔约束最有效的方法是什么?,z3,Z3,我认为这里有两个不同的相关案例: 案例1: 我有一组布尔变量,我想要另一个布尔变量,如果这些变量中的任何一个是真的,那么这个布尔变量就是真的。 我目前正在通过使布尔变量成为整数来实现这一点,然后使用以下形式的表达式进行设置: (ite(布尔表达式)1 0) 然后,我使用一个和和和一个大于 (>(+b1 b2 b3…)0) 案例2(这可能不是真正的伪布尔): 我有两组布尔变量: set1=n_1,n_2 set2=m_1,m_2 我想添加一个约束,即set1中设置为true的变量数等于set2中设
谢谢。您当前可以使用整数对PB约束进行编码。 必须将变量绑定在间隔0,1内。 例如:
(set-logic QF_LIA)
(declare-const n1 Int)
(declare-const n2 Int)
(assert (<= 0 n1))
(assert (<= n1 1))
(assert (<= 0 n2))
(assert (<= n2 1))
(assert (>= (+ n1 n2) 1))
(check-sat)
z3 ty.smt2 /v:10
(simplifier :num-exprs 10 :num-asts 171 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(propagate-values :num-exprs 10 :num-asts 171 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(ctx-simplify :num-steps 17)
(ctx-simplify :num-exprs 10 :num-asts 171 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(simplifier :num-exprs 10 :num-asts 171 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(solve_eqs :num-exprs 10 :num-asts 171 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(elim-uncnstr-vars :num-exprs 10 :num-asts 171 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(simplifier :num-exprs 10 :num-asts 173 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(pb2bv :num-exprs 4 :num-asts 180 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(simplifier :num-exprs 3 :num-asts 178 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(propagate-values :num-exprs 3 :num-asts 178 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(solve_eqs :num-exprs 3 :num-asts 178 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(max-bv-sharing :num-exprs 3 :num-asts 178 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(bit-blaster :num-exprs 3 :num-asts 178 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(aig :num-exprs 3 :num-asts 178 :time 0.00 :before-memory 0.77 :after-memory 0.77)
(ast-table :capacity 640 :size 178)
(sat-status
:inconsistent false
:vars 2
:elim-vars 0
:lits 2
:assigned 0
:binary-clauses 1
:ternary-clauses 0
:clauses 0
:del-clause 0
:avg-clause-size 2.00
:memory 0.77)