Knowledge Representation, Propositional Logic & Inference
Master formal logical reasoning in AI. Covers Knowledge Bases, Propositional Calculus, Truth Tables, Modus Ponens/Tollens, Resolution Refutation, Wumpus World navigation, and Horn Clauses.
KBS Architecture & Declarative vs Procedural Knowledge
A Knowledge-Based System consists of a Knowledge Base (storing facts and rules declaratively) and an Inference Engine (deriving new facts using domain-independent inference algorithms).
Representing knowledge explicitly as logical sentences (what is true), allowing the inference engine to reason about actions dynamically.
Propositional Calculus Syntax & Truth Tables
Propositional logic evaluates sentences built from atomic propositions (P, Q, R) and logical connectives (not ~, and ^, or v, implies =>, iff <=>).
Inference Rules: Modus Ponens, Tollens & Resolution
Inference rules derive new true sentences from existing premises without generating full exponential truth tables.
- ✓Apply Modus Ponens when antecedent P and rule P => Q are both affirmatively known.
- ✓Transform sentences to Conjunctive Normal Form (CNF) before applying resolution refutation.
- ✓Restrict knowledge representation to Horn clauses when real-time linear performance is critical.
- ✕Do not commit the fallacy of Affirming the Consequent (given P => Q and Q, inferring P).
- ✕Do not assume P => Q is false when P is False (an implication is vacuously True).
- ✕Do not execute cyclic backward chaining without an active recursion visited check.
- •Soundness guarantees no invalid conclusions are drawn; completeness ensures all truths are provable.
- •Horn clauses permit linear-time O(N) forward and backward chaining inference.
- •Resolution refutation proves a sentence by showing that the negation of the goal with the KB is unsatisfiable.
1% Knowledge Base2man(socrates).3mortal(X) :- man(X).45% Query: ?- mortal(socrates).6% Answer: Yes.
Yes.
Quick Syntax & Reference Sheet
| Concept / Rule | Syntax / Usage |
|---|---|
| Modus Ponens | P => Q, P |- Q |
| Modus Tollens | P => Q, ~Q |- ~P |
| Hypothetical Syllogism | P => Q, Q => R |- P => R |
| Disjunctive Syllogism | P v Q, ~P |- Q |
| Resolution Rule | P v Q, ~P v R |- Q v R |
| Implication Elimination | P => Q === ~P v Q |
| De Morgan 1 | ~(P ^ Q) === ~P v ~Q |
| De Morgan 2 | ~(P v Q) === ~P ^ ~Q |
| Horn Clause | P1 ^ P2 ^ ... ^ Pn => Q |
Common Pitfalls & Developer Mistakes
Assuming P => Q is false when P is False
Why it happens: An implication P => Q is vacuously TRUE whenever the antecedent P is False. It is ONLY false when P is True and Q is False.
Confusing Modus Tollens with Affirming the Consequent
Why it happens: Given P => Q and Q, concluding P is a logical fallacy. (e.g. 'If it rains the ground is wet. The ground is wet. Therefore it rained' is invalid because a sprinkler could have caused it).