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.
Horn and definite clause
We define an Horn clause as a special PL sentence in one of the two following forms:
- (conjunction of symbols) โ symbol, for example $๐ถ โง ๐ท โ ๐ต$
- propositional symbol, for example $A$. It is equivalent to $True \to A$.
A Horn clause is a clause with at most one positive literal, while a definite clause has exactly one positive literal.
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})
The resolution clause should only contain only one copy of each literal. The removal of multiple copies of literals is called factoring. For example, if we resolve $A \lor B$ with $A \lor \lnot B$, we obtain $A \lor A$, which is reduced to just $A$ by factoring.
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)
Resolution strategies
We can define some different resolution strategies and their completeness:
- Unit resolution: at least one of the parent clauses is a unit clause (it contains a single literal). Incomplete in general, but complete for Horn clauses.
- Input resolution: at least one of the two parent clauses is a member of the initial (i.e., input) set of clauses ($KB โง \lnot \alpha$). Incomplete in general, but complete for Horn clauses.
- Linear resolution: generalization of input resolution in which at least one of the parents is either in the initial set of clauses or is an ancestor of the other parent. Complete.
- Set of support resolution: given a set of support ๐ (which is a subset of the initial clauses such that the clauses not in ๐ are satisfiable), every resolution involves a clause in ๐ (the resolvent is added to ๐).
- ...
2) Forward chaining
The forward-chaining algorithm determines if a single proposition symbol โthe queryโis entailed by a knowledge base of definite clauses. It begins from known facts (positive literals) in the knowledge base. If all the premises of an implication are known, then its conclusion is added to the set of known facts. For example, if $A$ and $B$ are known and $A \land B \to C$ is in the knowledge base then $C$ can be added. This process continues until the query q is added or until no further inferences can be made.
In an AND-OR graph multiple edges joined by an arc indicate a conjunction while without an arc a disjunction. For example:
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
The backward-chaining algorithm, as its name suggests, works backward from the query.
If the query $q$ is known to be true, then no work is needed. Otherwise, the algorithm finds those implications in the knowledge base whose conclusion is $q$. If all the premises of one of those implications can be proved true (by backward chaining), then $q$ is true.
In summary:
- 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
Exam questions
2017 02 23 Q3 (7 points) Resolution
Consider the following knowledge base (KB) in propositional logic:
- $A \to \lnot B$
- $\lnot A \to \lnot B$
- $A \lor B$
Prove, using resolution with the input resolution strategy, $A \to B$ can be derived from the KB.
Solution
The first step is to trasform in CNF and add the negation of the solution:
- $\lnot A \lor \lnot B$
- $A \lor \lnot B$
- $A \lor B$
- $\lnot (\lnot A \lor B)$, with De Morgan's rules:
- $A$
- $\lnot B$
Then apply resolution:
(1) $\lnot A \lor \lnot B$ and (3) $A \lor B$ become $B \lor \lnot B$ and $A \lor \lnot A$
We have reached a fixed point because any other application of the resolution rule with the input resolution strategy will not produce any new knowledge.
So, $A \to B$ cannot be derived from the KB using resolution with the input resolution strategy.
2017 02 03 Q3 (6 points) Backward chaining
Consider the following knowledge base (KB) in propositional logic:
Prove, using backward chaining, if KB logically entails $Z$. Everything else being equal, apply the rules in the order given above. Report the generated tree and the order of expansion of its nodes.
Solution
Since $Z$ can be derived from KB using backward chaining, which is a sound inference procedure for propositional logic, then $Z$ is logically entailed by the KB.
2016 03 03 Q4 (6 points) Resolution with set of support
Consider the following knowledge base (KB) composed of formulas of propositional logic:
- $BatteryOK \land BulbsOK \to HeadlightsWork$
- $BatteryOK \land StarterOK \to EmptyGasTank \lor EngineStarts$
- $EngineStarts \to FlatTire \to CarOk$
- $HeadlightsWork$
- $BatteryOK$
- $StarterOK$
- $\lnot EmptyGasTank$
- $\lnot CarOK$
Prove if $FlatTire$ is true or false, by using the resolution inference procedure with the set of support strategy (considering the set of support composed of the goal clause and of any other clause already derived). Use the unit resolution strategy to break ties.
Solution
The KB converted in conjunctive normal form becomes:
- $\lnot BatteryOK \lor \lnot BulbsOK \lor HeadlightsWork$
- $\lnot BatteryOK \lor \lnot StarterOK \lor EmptyGasTank \lor EngineStarts$
- $\lnot EngineStarts \lor FlatTire \lor CarOk$
- $HeadlightsWork$
- $BatteryOK$
- $StarterOK$
- $\lnot EmptyGasTank$
- $\lnot CarOK$
The negation of the formula we would like to prove is:
- $\lnot FlatTire$
Applying resolution with set of support, considering initially $S=\lbrace\lnot FlatTire\rbrace$, and unit resolution to break ties, we get:
- $(3,9) \lnot EngineStarts \lor CarOk$$
- $(8,10) \lnot EngineStarts$
- $(2,11) \lnot BatteryOK \lor \lnot StarterOK \lor EmptyGasTank$
- $(5,12) \lnot StarterOK \lor EmptyGasTank$
- $(6,13) EmptyGasTank$
- $(7,14) \bot$
2015 02 07 Q4 (6 points) Forward chaining
Consider the following knowledge base (KB) composed of sentences of first- order logics modeling a plumbing system:
- $Pressurized(P1)$
- $Pressurized(P1) \land On(T1) \to Pressurized(P2)$
- $Pressurized(P2) \land On(T2) \to FlowShower$
- $FlowShower \to WetBathTube$
- $WetBathTube \land UnpluggedBathTube \to Flow(D2)$
- $Flow(D2) \to Flow(D1)$
- $Pipe(P1)$
- $Tap(T1)$
- $Tap(T2)$
- $Pipe(D2)$
- $On(T1)$
- $On(T2)$
- $UnpluggedBathTube$
Then solve the following questions:
- Apply forward chaining to the KB reported above to derive all the sentences entailed by the KB.
Solution
- $Pressurized(P2)$ from 1 + 11 + 2
- $FlowShower$ from 12 + 14 + 3
- $WetBathTubre$ from 15 + 4
- $Flow(D2)$ from 16 + 13 + 5
- $Flow(D1)$ from 17 + 6
- Modify (change, add, or remove sentences) the above KB to model that, when the bath tube is plugged and the shower flows, the floor is wet. If new predicates are introduced, the (intuitive) consistency with existing predicates should be explicitly enforced. For example, the bath tube cannot be both wet and dry. Hint: the KB does not need to contain only definite clauses.
Solution
$\lnot UnpluggedBathTube \land FlowShower \to WetFloor$
No Comments