3

这是我的简单编码。我想获得呈现所有这些约束的最终布尔 CNF。Z3求解器中是否有任何选项可以获得最终的布尔CNF?

x = Int('x')
y = Int('y')

c1 = And(x >= 1, x <= 10)
c2 = And(y >= 1, y <= 10)
c3 = Distinct(x,y)

s = Solver()
s.add(c1 , c2 , c3)
# I need the final Boolean CNF formula from Z3 solver...

感谢和问候

4

1 回答 1

3

正如 Ayrat 所说,使用目标和策略。这是一个例子:http ://rise4fun.com/Z3Py/4I3

x = Int('x')
y = Int('y')

c1 = And(x >= 1, x <= 10)
c2 = And(y >= 1, y <= 10)
c3 = Distinct(x,y)

g = Goal()
g.add(c1 , c2 , c3)

describe_tactics()

t = Tactic('tseitin-cnf')
print t(g)
于 2013-08-01T19:52:51.567 回答