Knowledge Representation in FOL

From Natural Language to Logical Formulas

Back to Lecture Overview

What is Knowledge Representation?

The Big Idea

Knowledge representation means describing facts about the world in a way that a computer (AI) can understand and reason with.

The Challenge:

In everyday language, we say things like: "Every student who takes a course learns something."

But a computer doesn't understand sentences like that! We need to translate them into a logical form using mathematical symbols.

The Solution:

First-Order Logic (FOL) provides a structured language with:

  • Predicates: Relations and properties
  • Variables: Represent objects
  • Quantifiers: Express generality (∀, ∃)
  • Logical Operators: Connect statements (∧, ∨, →)

Step-by-Step Knowledge Representation

"Every student who takes a course learns something."

Let's convert this natural language statement into FOL step by step...

1
Identify the Main Parts
Objects (Things in the world):
  • x = students
  • y = courses
Relations/Properties (Predicates):
  • Student(x) → "x is a student"
  • Takes(x, y) → "x takes course y"
  • Learns(x) → "x learns something"
Key Insight: We break down the English sentence into:
  • Variables (x, y) that represent objects
  • Predicates that describe properties and relationships
2
Express Using Logical Symbols

Now we want to say:

For every student x, and for every course y,
if x is a student and x takes course y,
then x learns something.

We write this as:

∀x ∀y ((Student(x)Takes(x, y)) → Learns(x))
Symbol Meanings:
  • = "for all" (universal quantifier)
  • = "and" (conjunction)
  • = "implies" (if...then)
  • Parentheses group related parts together
3
Understand What This Means

Let's break down the formula piece by piece:

  • ∀x ∀y → "For all students x and all courses y"
  • (Student(x)Takes(x, y)) → "if x is a student and x takes course y"
  • Learns(x) → "then x learns something"
Together it means:
"For every person x and course y, if x is a student who takes y, then x learns."
4
Why Use FOL for This?

FOL allows you to describe general rules, not just single facts.

Without FOL (Listing Every Case)
Student(ali) ∧ Takes(ali, CS221) → Learns(ali)
Student(sara) ∧ Takes(sara, AI101) → Learns(sara)
Student(omar) ∧ Takes(omar, ML202) → Learns(omar)
Student(fatima) ∧ Takes(fatima, DB301) → Learns(fatima)
...
// Need to list thousands of students!
With FOL (One General Rule)
∀x ∀y (Student(x) ∧ Takes(x, y)) → Learns(x)

// This ONE formula applies to everyone!
// Ali, Sara, Omar, Fatima, and anyone else.
The Power of Quantifiers: Instead of writing separate rules for each student, one formula with covers all cases—past, present, and future!
5
Why Is It Useful? (Automatic Reasoning)

FOL helps AI systems generalize and infer new facts automatically.

Example: AI Reasoning

If the AI knows:

1. Student(ali)
2. Takes(ali, CS221)
3. ∀x ∀y (Student(x)Takes(x, y)) → Learns(x)

↓ Automatic Inference ↓

It can automatically conclude:

Learns(ali)

That's reasoning! The AI didn't need to be explicitly told that Ali learns—it figured it out from the general rule.

More Examples of Knowledge Representation

Example 1: Family Relations

English: "Everyone has a mother"

∀x ∃y Mother(y, x)

For all people x, there exists someone y who is x's mother.

Example 2: Properties

English: "All birds have wings"

∀x (Bird(x)HasWings(x))

For all x, if x is a bird, then x has wings.

Example 3: Friendship

English: "If person x is a friend of y, then y is a friend of x"

∀x ∀y (Friend(x, y)Friend(y, x))

Friendship is symmetric (bidirectional).

Example 4: Grades

English: "Students who study hard pass exams"

∀x (StudiesHard(x)PassesExam(x))

For all x, if x studies hard, then x passes the exam.

Example 5: Transitivity

English: "If x is taller than y, and y is taller than z, then x is taller than z"

∀x ∀y ∀z ((Taller(x,y)Taller(y,z)) → Taller(x,z))

Height is transitive.

Example 6: Existence

English: "There exists a book that everyone has read"

∃x (Book(x)∀y Read(y, x))

There exists at least one book x such that every person y has read it.

Benefits of Knowledge Representation in FOL

Concept Meaning
Knowledge Representation Describing facts about the world in a structured way that computers can process
Why FOL? Because it can represent general rules using variables and quantifiers (∀, ∃)
Generalization One rule covers many situations—no need to list every individual case
Automatic Inference AI can derive new facts from existing knowledge using logical rules
Precision Unambiguous meaning—no confusion about what statements mean
Compositionality Complex statements built from simpler parts using logical operators

Summary

Key Takeaways:
  • Knowledge representation translates natural language into logical formulas
  • FOL uses predicates, variables, quantifiers, and operators to express facts
  • Universal quantifier (∀) expresses "for all" — general rules
  • Existential quantifier (∃) expresses "there exists" — specific instances
  • One FOL formula can replace thousands of individual statements
  • AI systems use FOL for automatic reasoning and inference
Remember:
"Every student who takes a course learns something"

∀x ∀y (Student(x) ∧ Takes(x, y)) → Learns(x)