Inference procedures for propositional logic
Our goal now is to decide whether $KB \models \alpha$ for some sentence $\alpha$.
Model checking
Reasoning with truth tables
Reasoning with truth tables is a form of semantic reasoning, in the sense that it directly exploits the definition of entailment: πΌ β¨ π½ holds when π½ in every model that makes πΌ true.
In PL, a model is an assignment of truth values (1 or 0, true or false, π or β₯) to every propositional symbol that appears in πΌ or π½ (or both)
Therefore, with π symbols we have 2π different models, which correspond to the rows of the truth table
For every model (row), we compute the truth vales of πΌ and π½ (by recursively computing the truth values of all the subsentences of πΌ and π½) Then we have that πΌ β¨ π½ if, and only if, every model (row) that assigns 1 to πΌ also assigns 1 to π½
Properties
This reasoning procedure is sound and complete. It always terminates, making reasoning in PL decidable.
However, it is inefficient when many propositional symbols are involved, because it has to compute a table of size 2πΓπ, where π is the number of propositional symbols and π is the number of subsentences the appear in the premises and the conclusion
Propositional satisfiability
Certain applications of PL require an agent to establish whether a set of sentences πΌ is or is not satisfiable
The problem of establishing the satisfiability of a set of propositional sentences is known as SAT Many interesting problems, including establishing propositional entailment, can be reduced to SAT
A (rather inefficient) solution of SAT is given by truth tables: πΌ is satisfiable if, and only if, it has truth value 1 in at least one row of its truth table
DPLL
Establish whether a set of sentences πΌ is or is not satisfiable
Preprocessing: convert every sentence in CNF (Conjunctive Normal Form)
Body of the procedure: from an empty assignment, incrementally try to build a model of πΌ
- if a model is built, πΌ is satisfiable
- if the algorithm terminates without being able to build a model, πΌ is unsatisfiable
Conjunctive normal form (CNF)
CNF (Conjunctive Normal Form) represents a sentence as a conjunction of clauses, where a clause is a disjunction of literals and a literal is either a propositional symbol or the negation of a symbol.
Every sentence of propositional logic is logically equivalent to a conjunction of clauses.
- π΄ β π΅ β¨ πΆ becomes Β¬π΄ β¨ π΅ β¨ πΆ
- πΆ β Β¬π· becomes Β¬πΆ β¨ Β¬π·
- (π΄ β π΅ β¨ πΆ) β§ (πΆ β Β¬π·) becomes Β¬π΄, π΅, πΆ , {Β¬πΆ, Β¬π·}
Unit clause: clause with only one literal; e.g., Β¬πΆ, πΆ
The steps to convert to CNF are (Consider π΄ β (π΅ β¨ πΆ)):
- Eliminate β, replacing Ξ± β π½ with Ξ± β π½ β§ π½ β Ξ±
- (π΄ β π΅ β¨ πΆ ) β§ ( π΅ β¨ πΆ β π΄)
- Eliminate β, replacing Ξ± β π½ with ¬α β¨ π½
- (Β¬π΄ β¨ π΅ β¨ πΆ) β§ (Β¬ π΅ β¨ πΆ β¨ π΄)
- Move Β¬ inwards using de Morgan's rules (Β¬ πΌ β§ π½ is equivalent to ¬α β¨ Β¬π½ and
Β¬ πΌ β¨ π½ is equivalent to ¬α β§ Β¬π½) and double-negation (¬¬πΌ is equivalent to πΌ)
- (Β¬π΄ β¨ π΅ β¨ πΆ) β§ ((Β¬π΅ β§ Β¬πΆ) β¨ π΄)
- Apply distributivity law (β§ over β¨) and flatten
- (Β¬π΄ β¨ π΅ β¨ πΆ) β§ (Β¬π΅ β¨ π΄) β§ (Β¬πΆ β¨ π΄)
DPLL algorithm
Essentially a backtracking (depth-first) search over models with some extras:
-
Early termination: stop when
- all clauses are satisfied: (π΄ β¨ π΅) β§ (π΄ β¨ Β¬πΆ) is satisfied by {π΄ = 1}
- any clause is falsified: (π΄ β¨ π΅) β§ (π΄ β¨ Β¬πΆ) is falsified by {π΄ = 0, π΅ = 0}
-
Pure literals: if all occurrences of a symbol in yet-unsatisfied clauses have the same sign, then give the
symbol that value
- in (π΄ β¨ π΅) β§ (π΄ β¨ Β¬πΆ) β§ (πΆ β¨ Β¬π΅), π΄ is pure and positive, so set it to true
- if there is a model, then there is a model also with {... , π΄ = 1, ... }
-
Unit clauses: if a clause has a single literal, set the corresponding symbol to satisfy clause
- in (π΄ β¨ π΅) β§ Β¬πΆ, Β¬πΆ must be set to true {πΆ = 0}
DPLL Example
Check if the set of sentences πΌ = {π΄ β π΅ β¨ πΆ, Β¬πΆ, π΄ β§ π΅ β π·, πΆ β Β¬π·} is satisfiable
Convert in CNF
- π΄ β π΅ β¨ πΆ becomes Β¬π΄ β¨ π΅ β¨ πΆ
- Β¬πΆ becomes Β¬πΆ
- π΄ β§ π΅ β π· becomes Β¬π΄ β¨ Β¬π΅ β¨ π·
- πΆ β Β¬π· becomes Β¬πΆ β¨ Β¬π·
Assignments | Clauses | Rule |
---|---|---|
Β¬A β¨ B β¨ C Β¬C Β¬A β¨ Β¬B β¨ D Β¬C β¨ Β¬D | unit clause Β¬C | |
Β¬C | Β¬A β¨ B T Β¬A β¨ Β¬B β¨ D T | pure literal Β¬A |
Β¬A | T T T T | early termination |
Conclusion: the set of sentences πΌ = {π΄ β π΅ β¨ πΆ, Β¬πΆ, π΄ β§ π΅ β π·, πΆ β Β¬π·} is satisfiable (because it is satisfied by any complete assignment extending {Β¬πΆ = 1, Β¬π΄ = 1})
Entailment via SAT
The problem of establishing propositional entailment can be reduced to a SAT problem, because πΌ β¨ π½ holds:
- if, and only if, every models that satisfies πΌ also satisfies π½
- equivalently if, and only if, no model satisfies both πΌ and Β¬π½
- equivalently if, and only if, πΌ β§ Β¬π½ is unsatisfiable
theorem-proving
Other than model checking entailment can be done by theorem provingβapplying rules of inference directly to the sentences in our knowledge base to construct a proof of the desired sentence without consulting models. If the number of models is large but the length of the proof is short, then theorem proving can be more efficient than model checking.
1) Resolution
Resolution is similar to DPLL (when this is used to establish entailment): it starts from a CNF representation of the premises and the negation of the conclusion
Resolution applies (in all the possible ways) the resolution rule to the clauses (original ones and those derived by the previous applications of the resolution rule)
Suppose πΆ1, πΆ2 are clauses such that literal β1 in πΆ1 and literal β2 in πΆ2 are complementary (same propositional symbol with different sign), then clauses πΆ1, πΆ2 can be resolved into a new clause πΆ called resolvent C = (πΆ1 β {β1}) βͺ (πΆ2 β {β2})
Resolution properties
- Propositional resolution is an extremely powerful rule of inference for PL
- It works by refutation: to prove that KB β¨ πΌ it proves that KB β§ Β¬πΌ is unsatisfiable, namely it builds a refutation for KB β§ Β¬πΌ by looking for the empty clause
- Using propositional resolution, it is possible to build a theorem prover that is sound and complete for PL
- Resolution rule is sound
- Theorem: resolvent πΆ is satisfiable if and only if clauses πΆ1, πΆ2 are simultaneously satisfiable
- Since resolvent is smaller than parent clauses, resolution stops at some point
- Propositional resolution works on any set of sentences in clausal form (CNF)
2) Forward chaining
- Forward chaining considers definite clauses and applies Modus Ponens to generate new facts:
- Modus Ponens: given π" β§ π# β§ β― β§ π$ β π and π", π#, ..., π$, infer π
- Forward chaining keeps applying this rule, adding new facts, until nothing more can be added
Properties of forward chaining
Forward chaining is sound and complete for KBs composed of definite clauses
- Soundness: follows from soundness of Modus Ponens (easy to check)
- Completeness: the algorithm reaches a a fixed point from where no new atomic sentences can be derived
Forward chaining can only derive new positive literals (facts), it cannot derive new rules
3) Backward chaining
Backward chaining works like forward chaining, but backward:
- Start from the goal (query) π, which is a positive literal
- To prove π, check if π is already in the KB, otherwise prove all the premises of a rule concluding π
- Avoid loops: check if new subgoal is already on the goal stack
- Avoid repeated work: check if new subgoal has already been proved true, or has already failed
Backward chaining is sound and complete for KBs composed of definite clauses