← Back to Tutorials

13. Knowledge Representation

Knowledge Representation

Why Knowledge Representation?

For AI systems to reason intelligently, they need a way to represent knowledge about the world. Knowledge representation (KR) is the study of how to encode knowledge in a form that computers can use for inference and problem-solving.

Techniques

Propositional Logic

Propositional logic uses boolean variables (propositions) and logical connectives: AND (∧), OR (∨), NOT (¬), IMPLIES (→).

Propositions:
  P: "It is raining"
  Q: "The ground is wet"

Rules:
  P → Q        (If raining, ground is wet)
  P            (It is raining)
  ∴ Q          (Therefore, ground is wet) — Modus Ponens

First-Order Logic (FOL)

FOL extends propositional logic with quantifiers (∀ for all, ∃ there exists) and predicates that describe relationships between objects.

∀x (Man(x) → Mortal(x))     (All men are mortal)
Man(Socrates)                (Socrates is a man)
∴ Mortal(Socrates)           (Therefore, Socrates is mortal)

Inference Rules

Unification & Resolution

Unification finds substitutions that make two logical expressions identical. Resolution is a complete inference rule for FOL that proves statements by contradiction.

Practice Task: Represent the following in FOL: "All students like AI. John is a student. Therefore John likes AI." Perform forward chaining to prove "John likes AI." Represent a family tree using FOL predicates (Parent, Sibling) and infer three new facts using resolution.