I'm looking for ideas on how to encode mathematical equations into cnf-sat form, so that they can be solved by an open source SAT solver like MiniSat.
So, how do I convert something like:
3x + 4y - z = 14
-2x - 4z <= -6
x - 3y + z >= 15
into a propositional equation that can be solved by using SAT Solvers.
Any suggestions because I'm stumped??
答案 0 :(得分:4)
我假设你正在寻找方程的整数解,因为Integer Linear Programming是一个已知的NP难问题,就像SAT一样。 (当然,没有整数约束的线性编程在P中。)
您可以将方程式转换为SAT实例,但是学习如何使用SMT求解器可以更有效地花费时间,这样可以更自然地表达方程式。例如,使用Microsoft的Z3 solver,您可以使用这个简单的程序解决上面的等式:
(declare-fun x () Int)
(declare-fun y () Int)
(declare-fun z () Int)
(assert (= (+ (* 3 x) (* 4 y) (- z)) 14))
(assert (<= (- (* (- 2) x) (* 4 z)) (- 6)))
(assert (>= (+ (- x (* (- 3) y)) z) 15))
(check-sat)
(get-model)
您可以paste that program进入an online Z3 sandbox并点击播放按钮,看看它是否解决方程式。