conjunctive normal form, MiniSat
SAT SAT solver to solve the problem of programs collectively, introduce some prior knowledge, as well as miniSAT this open source SAT solver here.
Some Definitions
variable
those values boolean function which uses a variable called, for example: (¬a ∨ b ⊕ x) , a, b, x is its variable, of course, to take what your name variable may be used.literal
in boolean function actually appearing variable called literal, wherein with NOT (negation, ¬) called negative literal, is not called positive literal, for example: (¬a ∨ a), there is a negative literal, positive literal one each.clause
clause is a parenthesis all only OR (disjunction, ∨), for example, (x1 ∨ ¬x2) ∧ (¬x1 ∨ x2 ∨ x3) ∧ ¬x1, which will have three clause (the last is a single such ¬x1) .
conjunctive normal form
conjunctive normal form CNF for short, the digital circuit also called product of sums (to make up a pile of the meaning in the AND OR), is simply a pile up to the AND clause.
|
|
Can be found in an article cited Circuit satisfiability problem, four-color problem is CNF forms and discuss data SAT, and SAT solver are eating with CNF format, because after us:
- Any boolean function can be converted to CNF
can use the double negative law, De Morgan's laws , distributive law will all turn into a boolean function CNF form (assuming that there are people who will come to see the point of this article, will be studied logic design and the like things right).
|
|
CNF has good structure
a clause there as long as there is a true, that the clause on as true (because clause in all for OR). All clause must be as true, boolean function will be to true (as per the clause AND up).First of all such forms are well understood (note that most of us can write the program, if the conditions will probably be written AND of ORs).
In the coming big column (b) conjunctive normal form, MiniSat Imagine you have thousands variable to be disposed of, this time the entire boolean function again increase hundreds variable related to go in, CNF simply in the new logical AND on the line.
最後當我們在解決 SAT 問題,對一個 variable assign true 或 false 來測試 boolean function 時,簡單的檢查有沒有 clause 全部的 literal 都是 false 就能知道這樣的賦值方式會不會 unsatisfiable。
試想一下你有一個邏輯非常複雜,一大堆的巢狀邏輯包在一起的時候,你如何處理以上的情況? 比起殺死一堆腦細胞,簡化問題是更好的作法。
DIMACS CNF format
餵給 SAT solver 吃的 CNF 有個通用的格式叫 DIMACS CNF format,就是副檔名叫 XXX.cnf 的純文字檔。
|
|
這裡可以找到一系列問題的 DIMACS 檔案
http://www.cs.ubc.ca/~hoos/SATLIB/benchm.html
MiniSat
MiniSat is a great SAT solver, won a series of SAT champion in 2005, is more important is that it is open source , and only a few thousand lines simple and concise code, can be studied after the adoption of the MiniSat, to have a relatively high starting point for the homemade SAT solver.
reference
wiki SAT
https://en.wikipedia.org/wiki/Boolean_satisfiability_problem
wiki CNF
https://en.wikipedia.org/wiki/Conjunctive_normal_form
CNF format
http://people.sc.fsu.edu/~jburkardt/data/cnf/cnf.html