CSC 494 · Introduction to Artificial Intelligence
Our notes
2 min readKnowledge-based agents
A knowledge base (KB) is a set of sentences in a formal language. The agent TELLs the KB what it perceives and ASKs it what to do; an inference procedure derives new sentences.
Propositional logic
- Atoms: P, Q, R (true or false).
- Connectives: ¬ (not), ∧ (and), ∨ (or), ⇒ (implies), ⇔ (if and only if).
- A model assigns true or false to every atom.
- Valid: true in all models (P ∨ ¬P). Satisfiable: true in some model. Unsatisfiable: true in none.
Entailment
KB ⊨ α (KB entails α) if α is true in every model in which the KB is true.
Model checking: list all models (truth table) and check. With n atoms there are 2ⁿ models.
Inference rules
- Modus ponens: from α ⇒ β and α, infer β.
- And-elimination: from α ∧ β, infer α.
- Resolution: from (α ∨ β) and (¬β ∨ γ), infer (α ∨ γ).
An inference procedure is sound if it derives only entailed sentences, complete if it can derive every entailed sentence.
Conjunctive normal form (CNF)
A conjunction of clauses (each a disjunction of literals). Convert by: eliminate ⇔ and ⇒ (α ⇒ β becomes ¬α ∨ β), move ¬ inwards (De Morgan), distribute ∨ over ∧.
Resolution refutation
To prove KB ⊨ α: add ¬α to the KB in CNF and resolve until the empty clause (a contradiction) appears.
Worked example
KB: P ⇒ Q, Q ⇒ R, P. Prove R.
- Clauses: (¬P ∨ Q), (¬Q ∨ R), (P), and the negated goal (¬R).
- Resolve (¬R) with (¬Q ∨ R) → (¬Q).
- Resolve (¬Q) with (¬P ∨ Q) → (¬P).
- Resolve (¬P) with (P) → empty clause.
Contradiction, so R is proved. (A truth table agrees: in every model where the KB is true, P, Q and R are all true.)
Horn clauses and chaining
A Horn clause has at most one positive literal (rules like P ∧ Q ⇒ R). For Horn KBs, forward chaining (data-driven: fire rules whose premises are known) and backward chaining (goal-driven: work back from the query) are efficient (linear time). Prolog uses backward chaining.
Exams usually ask
- Define entailment, validity and satisfiability.
- Convert sentences to CNF and prove a query by resolution.
- Compare forward and backward chaining.
Common mistake
Forgetting to negate the goal before resolution. Resolution refutation proves α by showing KB ∧ ¬α is impossible.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Propositional logic
(opens en.wikipedia.org in a new tab)
Wikipedia, Propositional logic, CC BY-SA 4.0 · licence
-
Resolution (logic)
(opens en.wikipedia.org in a new tab)
Wikipedia, Resolution (logic), CC BY-SA 4.0 · licence
-
forall x: Calgary, an introduction to formal logic (whole book, read online)
The free textbook whose exercises the solutions booklet answers. Read online, or the PDF is about 1.6 MB.
(opens forallx.openlogicproject.org in a new tab)
forall x: Calgary, forall x: Calgary, an introduction to formal logic (whole book, read online), CC BY 4.0 · licence
-
NPTEL: Artificial Intelligence: Knowledge Representation and Reasoning (IIT Madras, whole course)
Prof. Deepak Khemani: propositional and first-order logic, proofs, unification and resolution, representing knowledge. Video lectures, many hours in all: watch on Wi-Fi where you can.
(opens nptel.ac.in in a new tab)
NPTEL, NPTEL: Artificial Intelligence: Knowledge Representation and Reasoning (IIT Madras, whole course), CC BY-NC-SA 4.0 · licence
Watch
-
Best pick Propositional Logic − Logical Equivalences
17 min · ≈ 77 MB · about ₦43
(opens youtube.com in a new tab)
-
Inference Rules Modes Ponens Modes Tollens in Propositional Logic in Artificial Intelligence
9 min · ≈ 41 MB · about ₦23
(opens youtube.com in a new tab)
-
Agents based on Propositional logic |Artificial Intelligence |SNS INSTITUTIONS
6 min · ≈ 27 MB · about ₦15
(opens youtube.com in a new tab)
-
Inferences in Propositional Logic-Artificial Intelligence-Logical Reasoning-Equivalence-Patterns
19 min · ≈ 86 MB · about ₦48
(opens youtube.com in a new tab)
-
inference rules in propositional logic in ai | inference rules in propositional logic
18 min · ≈ 81 MB · about ₦45
(opens youtube.com in a new tab)
Practise
-
forall x: Calgary, solutions to selected exercises (PDF, 0.5 MB)
Answers to the exercises in the free forall x book: arguments and validity, truth tables, natural deduction, first-order logic.
(opens forallx.openlogicproject.org in a new tab)
forall x: Calgary, forall x: Calgary, solutions to selected exercises (PDF, 0.5 MB), CC BY 4.0 · licence
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.