Outline
- Conjunctive Normal Form
- In-Class Exercise
- Resolution algorithms
- Horn Clauses
Introduction
- We have been looking at automated theorem proving in proof systems as a method for logical agents to reason about their knowledge bases and select what actions to take next.
- So far, we have considered two kinds of proof systems: natural deduction and resolution refutations.
- We said we were going to focus on resolution since refutations are found from a set of clauses using only has one rule of inference as opposed to the many different rules of inference that are allowed in natural deduction, making searching for refutations more mechanical in nature.
- Recall in a resolution refutation we have a starting set of clauses `Gamma` which are based usually on our knowledge base and the statement we are trying to show. Here a clause is a set `{L_1, ..., L_m}` where `L_i` is either a propositional variable or its negation. The intended meaning of a clause is
`L_1 vv ... vv L_m`.
- Resolution is the inference:
`({L_1, ... , L_m}, {\bar{L}_m vv L_1' vv ...vv L_n'})/({L_1, ..., L_(m-1), L_1', ... , L_n'})`
- A resolution refutation of a set of clauses `Gamma` is a sequence of clauses `R_1, ..., R_m` where `R_m = {}` such that for `1 leq i leq m`, `R_i in Gamma` or for some `j,k < i`, `R_i` follows from `R_j` and `R_k` by resolution.
- Last day, we gave an example of refuting the negation of the pigeonhole principle `\neg PHP_1^2` using a resoluton refutation.
- We begin today by continuing our discussion of resolution.
Conjunctive Normal Form
- Notice resolution works on an AND of OR's of literals.
- Any propositional formula can be rewritten into one which is equivalent to an AND of ORs of literals. This equivalent form is called Conjunctive Normal Form.
- To see this just write down the truth table for the formula, and consider the rows for which the formula is false. That one of these rows doesn't happen can be written as an OR of literals. That all of these false rows don't happens, is just an AND of these ORs.
- Another way to see this is via formula rewriting: One uses implication and biconditional elimination, followed by DeMorgan laws.
Example of Converting to CNF
- Consider the statement `(A wedge B) \vee (bar(A) wedge bar(B))\vee (A wedge neg B)`. If we view True as `1` and False as `0`. This expresses `A ge B`.
- We could express `A = max(A, B, C)` as `A ge B wedge A ge C`.
- This is an AND of ORs of ANDs as written, so not CNF.
- Its truth table looks:
A | B | C | A = max(A, B, C) |
True | True | True | True |
True | True | False | True |
True | False | True | True |
True | False | False | True |
False | True | True | False |
False | True | False | False |
False | False | True | False |
False | False | False | True |
- To make a CNF, we look at the three false rows. If the variable `X` for a column has a false in it we take that variable, if it has a true we take take `bar(X)`. So the row False, True, False, becomes `A vee bar(B) vee C`.
- This formula asserts that row didn't happen.
- So the CNF for the whole formula is:
`(A vee bar(B) vee bar(C)) wedge (A vee bar(B) vee C) wedge (A vee B vee bar(C))`
- As a collection of clauses we would write:
`{{A, bar(B), bar(C)}, {A, bar(B), C}, {A, B, bar(C)}}.`
In-Class Exercise
- Consider the formula `((A => (B ^^ C)) => D`.
- Rather than use the truth table approach, use formula re-writing (show steps) to convert this to conjunctive normal form.
- Post your solution to the Oct 26 In-Class Exercise Thread.
An Algorithm For Resolution
- Inference procedures based on resolution work by trying to produce a refutation.
- We take `KB ^^ neg alpha` (that is, the negation of `KB => alpha`) and convert it to a CNF formula.
- We then cycle over pairs of clauses and for each pair that contains a resolvable literal we resolve the clauses.
- We keep repeating until no new clauses can be derived.
- If we ever resolve and get the empty clause (equivalent to false), then we know `KB` entails `alpha`.
Example
- Consider the statement about natural numbers: `K le M` or `M le K`.
- To use propositional logic and resolution to show such a statement, we might consider `n`-bit variants of the statement, and show each `n`-bit variant is true.
- If we know, `K` and `M` are `n`-bit numbers, we can use propositional variables `K_1, ... K_n` and `M_1, ..., M_n` to represent these numbers. So `K le M` can be expressed as the OR over `j` of statements saying:
`(K_n iff M_n) wedge ... wedge (K_(j+1) iff M_(j+1)) wedge (neg K_(j) wedge M_j)`.
I.e., the high order bits are the same until `j` where `K_j` must be True and `M_j` must be False.
- Let's give a resolution refutation of the 1-bit version of `K le M` or `M le K`.
- This is just the statement: `(K_1 iff M_1) vee (M_1 wedge neg K_1) vee (K_1 iff M_1) vee (K_1 wedge neg M_1) ` which is the same as
`(K_1 iff M_1) vee (M_1 wedge neg K_1) vee (K_1 wedge neg M_1)`
- As a first step, we convert the negation of this formula to CNF using DeMorgan's Laws:
`{{K_1, M_1}, {bar(K_1), bar(M_1)}, {bar(K_1), M_1}, {K_1, bar(M_1)}}`.
- Resolving the first and third clause gives `{M_1, M_1} = {M_1}`. Resolving the second and fourth clause gives `{bar(M_1), bar(M_1)} = {bar(M_1)}`. Then resolving these two gives the empty clause, completing the refutation.
Completeness
- To show resolution is complete we need to show that if a set of clauses is unsatisfiable then the resolution closure contains the empty clause.
- To prove this we actually show the contrapositive: If the resolution closure (RC) does not contain the empty clause then there is a satisfying assignment.
- The following procedure gives us the satisfying assignment:
For i from 1 to k (where i cycles over variable indexes):
- If there is a clause in RC(S) containing the literal `neg P_i` and all its other literals are false under the assignment chosen for `P_1, ... P_(i-1)` then assign false to `P_i`.
- Otherwise, assign true to `P_i`.
Example No Refutation
- Suppose we only had the following two clauses from the example a couple of slides back:
`{bar(K_1), M_1}, {K_1, bar(M_1)}`
- Then the resolution closure of these two clauses is:
`{bar(K_1), M_1}, {K_1, bar(M_1)}, {M_1, bar(M_1)}, {K_1, bar(K_1)}`.
- Letting `P_1 = K_1`, and `P_2 = M_1`. This gives:
`{bar(P_1), P_2}, {P_1, bar(P_2)}, {P_2, bar(P_2)}, {P_1, bar(P_1)}`.
- When `i=1`, in the for loop of the last slide, no assignments have been made so there is no clause in which all the other variables have been assigned False containing `bar(P_1)`. So we set `P_1` to True in our model.
- When `i=2`, again we don't find such a clause, so `P_2` is assigned true.
- Substituting back for `K_1` and `M_1` we get both of these would be assigned true by this algorithm. Notice this assignment does satisfy both clauses in:
`{bar(K_1), M_1}, {K_1, bar(M_1)}`
- Suppose we had started with the three clauses:
`{bar(P_1)},{bar(P_1), P_2}, {P_1, bar(P_2)}`
- In this case, the resolution closure would be:
`{bar(P_1)}, {bar(P_2)}, {bar(P_1), P_2}, {P_1, bar(P_2)}, {P_2, bar(P_2)}, {P_1, bar(P_1)}.`
- In the for loop when `i=1`, the first clause will force `P_1` to be false; when `i=2`, the second clause, will force `P_2` to be false. One can verify the `P_1->`False, `P_2->`False assignment in fact makes all of the clauses we started with true.