Application of propositional logic
Application of propositional logic
Logic Circuits
A Sudoku Puzzle
Modelling A Sudoku Puzzle
- propositional variables : “the number at the cell is ”
- known entries: if the number at is
- every cell contains at most one number:
- for each number , each row contains at least one
- : for each number , each column contains at least one . (Similar with )
- for each number , every 3 ˆ 3 block contains at least one
数独有解,当且仅当存在一个真值指派,使得 为真。
Sub-classes of Propositions
Definition 1. A tautology (重言式, 永真式) is a compound proposition that is always true, no matter what the truth values of the propositional variables are. In other words, is a tautology if for any truth assignment .
Definition 2. A contradiction (矛盾式) is a compound proposition that is always false, no matter what the truth values of the propositional variables are. In other words, is a contradiction if for any truth assignment .
Definition 3. A compound proposition is satisfiable (可满足的) if it is true under some truth assignment. In other words, is satisfiable if there exists a truth assignment such that
Example 4. is a tautology, and is satisfiable.
Example 5. is a contradiction, and is not satisfiable.
Example 6. is not a tautology, is not a contradiction, and is satisfiable.
Theorem 7.
- is a tautology.
- is a contradiction.
Theorem 8.
- is a tautology if and only if is a contradiction.
- is a contradiction if and only if is a tautology.
- is satisfiable if and only if is not a contradiction.
- is a tautology if and only if is not satisfiable.
Theorem 9.
- if and only if is not satisfiable.
- if and only if is a tautology.
- if and only if and .
Theorem 10.
If , then
- is a tautology iff is a tautology.
- is a contradiction iff is a contradiction.
Theorem 11.
- If and , then .
- If and , then .
- If and , then .
想要判断一个命题是否可满足,最直接的方法就是尝试所有真值指派。比如数独的例子,需要尝试 种可能性。但计算量太大,完全穷举不合理的。
Normal Forms (范式)
Definition 12. Normal Form
- A literal is a propositional variable or its negation. (比如说 这种)
- A conjunctive clause (合取子句) is a conjunction of literals. (例如 ,同时 这种只有一个 literal 的也算)
- A disjunctive clause (析取子句) is a disjunction of literals.
- A compound proposition is in disjunctive normal form (DNF, 析取范式) if it is a disjunction of conjunctive clauses. (典型的有 这种; 也算,可以看作一个合取子句)
- A compound proposition is in conjunctive normal form (CNF, 合取范式) if it is a conjunction of disjunctive clauses.
Remark.
A conjunctive clause may have only one literal, which can be treated as a conjunction of only one literal (退化情况). A DNF proposition may have only one conjunctive clause, which can be treated as a disjunction of only one conjunctive clause (退化情况).
Theorem 13. Every compound proposition is logically equivalent to some compound proposition in disjunctive normal form.
Theorem 14. Every compound proposition is logically equivalent to some compound proposition in conjunctive normal form.
任何复合命题都有逻辑等价的合取范式或是析取范式。
假如命题被写成 DNF 的形式,那么只要找到一个真值指派,使得其任意一个子句为真,就是可满足的。
Basic observations:
- It is easy to determine whether a DNF proposition is SAT.
- It is hard to determine whether a generic proposition is SAT.
- It is impossible to turn every proposition into a concise DNF expressions (if preserving logic equivalence).
就是说把一个复合命题转换成 DNF,这个 DNF 的长度可能是指数级的。这说明走 DNF 这条路是走不通的。 - It is still hard to determine whether a CNF proposition is SAT, but this problem is easier to analysis.
这个时候就需要找到一个真值指派,使得 CNF 中的每个真值指派都为真。
但是把一个复合命题转换成 CNF,这个 CNF 的长度可能是指数级的。问题依然没有得到解决。
SAT solver
现有的解决办法是,我们把一个复合命题转化为 CNF,但是不需要逻辑等价,只需要保持可满足性相同。
Generating CNF expressions
例如
- 都是新引入的原子命题。第一行和第二行的式子的可满足性是一样的。
- 不过第二行目前还不是 CNF,但是也不难将其变为长度合理的合取范式,例如
注意到最多有四个子句,每个子句至多有三个命题变元。
