Skip to content
ml-recall

Topic notes

Knowledge Representation & Reasoning

How symbolic AI stores and uses knowledge — representations, propositional and first-order logic, entailment and resolution, rule-based systems, near-miss learning and knowledge-graph embeddings.

4-min read AI-checked

Practise 69 questions Take a test

Key ideas

Knowledge is not information. In the DIKW pyramid, data are raw symbols, information is interpreted data, knowledge is information actively integrated into our model of the world, and wisdom is knowing when to use it1. Top-down (symbolic) AI rests on representing knowledge and reasoning with it.

Representations form a spectrum1. At the simple end is algorithmic knowledge (a program: directly usable by a computer, but inflexible); at the other end natural language (most expressive, unusable for automatic reasoning). In between: network representations (semantic nets, stored as object–attribute–value triples), hierarchical ones (frames with slots, default values and inheritance; a scenario is a frame for a situation that unfolds in time), procedural ones (production rules) and logic (predicate logic, Horn clauses in Prolog, description logics).

Propositional semantics (truth tables)2,7:

Concept Definition One good row is enough to show…
tautology true on every valuation …that it is not a tautology
contradiction false on every valuation …that it is not a contradiction
jointly satisfiable some valuation makes all true …that they are satisfiable
valid argument / KB⊨αKB \models \alpha no valuation makes premises true and conclusion false …that it is invalid

Key equivalences: P1,…,Pn⊨CP_1,\dots,P_n \models C iff (P1∧⋯∧Pn)→C(P_1\land\dots\land P_n)\to C is a tautology iff {P1,…,Pn,¬C}\{P_1,\dots,P_n,\lnot C\} is unsatisfiable; unsatisfiable premises entail everything2. Also A→B≡¬A∨B≡¬B→¬AA\to B \equiv \lnot A\lor B \equiv \lnot B\to\lnot A (contrapositive), but A→BA\to B is not equivalent to B→AB\to A.

Normal forms and completeness. Every sentence has an equivalent CNF (a conjunction of clauses); the truth-table method writes one clause per false row7. {¬,∧,∨}\{\lnot,\land,\lor\}, {¬,→}\{\lnot,\to\} and NAND alone are functionally complete; {∧,∨,→}\{\land,\lor,\to\} is not, because every sentence built from them is true when all letters are true, so it cannot express ¬A\lnot A7. Formulas without ¬\lnot express exactly the monotone conditions — making one more letter true can never make them false8. So "at least kk of nn true" is expressible, while "exactly kk" and parity are not.

Resolution works on CNF clauses: from (A∨X)(A\lor X) and (¬A∨Y)(\lnot A\lor Y) infer (X∨Y)(X\lor Y). To prove KB⊨αKB\models\alpha, add ¬α\lnot\alpha and derive the empty clause. It is sound and refutation-complete; in first-order logic it needs unification (a substitution making two literals identical, ideally the most general one)3.

First-order logic. Truth is relative to an interpretation (domain + meanings). There is no truth-table test for FOL validity: a sentence has infinitely many interpretations, though one counter-interpretation refutes it7. Quantifier order matters7. Useful facts: ∃y ∀x L(x,y)⊨∀x ∃y L(x,y)\exists y\,\forall x\,L(x,y)\models\forall x\,\exists y\,L(x,y) but not conversely; ¬∀x F(x)≡∃x ¬F(x)\lnot\forall x\,F(x)\equiv\exists x\,\lnot F(x)7; if xx is not free in GG, ∀x (F(x)→G)≡∃x F(x)→G\forall x\,(F(x)\to G)\equiv\exists x\,F(x)\to G and ∃x (F(x)→G)≡∀x F(x)→G\exists x\,(F(x)\to G)\equiv\forall x\,F(x)\to G. N(a)∧N(b)∧N(c)N(a)\land N(b)\land N(c) does not entail ∀x N(x)\forall x\,N(x), since the domain may contain unnamed objects7.

Rule-based (expert) systems have a working memory of facts, a knowledge base of IF–THEN rules and an inference engine1. Forward chaining is data-driven: fire rules whose conditions hold until nothing new (or the goal) is added. Backward chaining is goal-driven: pick rules that conclude the goal and recursively prove their conditions — natural for diagnosis 1. The engine loops match → resolve conflicts → act; matching is the expensive phase, and the Rete algorithm keeps partial matches between cycles and only processes changes to working memory4. Conflict resolution picks one instantiation from the conflict set: rule order, salience, recency (newest fact), specificity (most conditions); refraction stops the same instantiation firing twice4.

Near-miss (arch) learning (Winston) updates a model from one example at a time5:

Seen Heuristic Effect
near miss (differs in exactly one feature) require-link, forbid-link specialise
positive example drop-link, extend-set, climb-tree, close-interval generalise

Example: the model allows only red; a yellow positive example → extend-set to {red, yellow}. Positive examples with incandescent and with fluorescent bulbs → climb-tree to "light source". A near miss that differs only by an orange colour → forbid-link orange5.

Knowledge-graph embeddings score triples (s,r,o)(s, r, o)6: TransE wants es+er≈eo\mathbf{e}_s+\mathbf{e}_r\approx\mathbf{e}_o (small distance = plausible fact); DistMult uses a diagonal bilinear score, which is symmetric in ss and oo; ComplEx uses complex vectors and the conjugate of the object, so it can model antisymmetric relations; RotatE rotates es\mathbf{e}_s element-wise by unit-modulus rk=eiθkr_k=e^{i\theta_k}.

Formulas

fTransE=∥es+er−eo∥,fDistMult=∑kes,k rk eo,k,fComplEx=Re(∑kes,k rk eo,k‾)f_{\text{TransE}}=\lVert\mathbf{e}_s+\mathbf{e}_r-\mathbf{e}_o\rVert,\qquad f_{\text{DistMult}}=\sum_k e_{s,k}\,r_k\,e_{o,k},\qquad f_{\text{ComplEx}}=\mathrm{Re}\Big(\sum_k e_{s,k}\,r_k\,\overline{e_{o,k}}\Big)

RotatE: eo≈es∘r\mathbf{e}_o\approx\mathbf{e}_s\circ\mathbf{r}; a symmetric relation needs r∘r=1\mathbf{r}\circ\mathbf{r}=\mathbf{1}, i.e. every θk∈{0,π}\theta_k\in\{0,\pi\}. ComplEx with a purely real r\mathbf{r} is symmetric again.

Worked example

KB={P∨Q, ¬P∨R, ¬Q∨S, ¬R}KB=\{P\lor Q,\ \lnot P\lor R,\ \lnot Q\lor S,\ \lnot R\}. Does KB⊨SKB\models S? Add ¬S\lnot S and resolve: (¬P∨R)+¬R⇒¬P(\lnot P\lor R)+\lnot R\Rightarrow\lnot P; (P∨Q)+¬P⇒Q(P\lor Q)+\lnot P\Rightarrow Q; (¬Q∨S)+Q⇒S(\lnot Q\lor S)+Q\Rightarrow S; S+¬S⇒S+\lnot S\Rightarrow empty clause. So KB⊨SKB\models S. Check by truth table: only 1 of the 16 valuations satisfies KBKB (P,RP,R false; Q,SQ,S true), and SS is true on it.

Common pitfalls

References

  1. AI for Beginners — Lesson 2: Knowledge Representation; Classifying Computer Knowledge Representations; Expert Systems; Forward vs. Backward Inference
  2. forall x: Calgary — An Introduction to Formal Logic — Ch. 12 Semantic concepts (§12.1–12.6)
  3. Wikipedia: Resolution (logic) — Resolution in propositional logic (A resolution technique); Resolution in first-order logic
  4. Wikipedia: Rete algorithm — Overview; Description (Conflict resolution)
  5. MIT OpenCourseWare 6.034 Artificial Intelligence (Fall 2010) — quizzes, finals and tutorial notes — Mega-Recitation 7: Near Misses, Arch Learning (transcript)
  6. Wikipedia: Knowledge graph embedding — Models (Tensor decomposition models — bilinear; Geometric models — translational, roto-translational)
  7. forall x: Calgary — An Introduction to Formal Logic — Ch. 15 Partial truth tables (closing summary table); Ch. 25.3 The order of quantifiers; Ch. 31 Truth in FOL; Ch. 34 Reasoning about interpretations; Ch. 38 Conversion of quantifiers; Ch. 45.3 Conjunctive normal form; Ch. 46 Functional completeness (46.1, 46.2)
  8. Wikipedia: Monotonic function — In Boolean functions