Building the Foundation of Intelligent Reasoning
A knowledge base is more than just a storage system—it's a structured collection of sentences, axioms, and inference rules that enable intelligent reasoning.
Sentences are the basic building blocks of a knowledge base. They represent facts about the world and rules that govern relationships between facts.
// Facts
is_bird(tweety)
has_wings(tweety)
is_red(apple1)
is_sweet(apple1)
// Rules
can_fly(X) :- is_bird(X), has_wings(X)
is_fruit(X) :- is_red(X), is_sweet(X)
if can_fly(X) then is_animal(X)
Axioms are fundamental truths that are assumed to be true without proof. They form the foundation upon which all other knowledge is built.
// Logical Axioms
∀x (P(x) ∨ ¬P(x)) // Law of excluded middle
∀x (P(x) → P(x)) // Reflexivity
∀x,y (P(x) ∧ P(y) → P(x) ∧ P(y)) // Conjunction
// Domain Axioms
∀x (bird(x) → has_wings(x)) // All birds have wings
∀x (mammal(x) → warm_blooded(x)) // All mammals are warm-blooded
∀x (fish(x) → lives_in_water(x)) // All fish live in water
Inference rules specify how to derive new sentences from existing ones. They are the "engine" that powers logical reasoning.
// Given knowledge base:
1. bird(tweety) // Fact
2. ∀x (bird(x) → can_fly(x)) // Rule
3. ∀x (can_fly(x) → is_animal(x)) // Rule
// Using Modus Ponens:
4. can_fly(tweety) // From 1, 2
5. is_animal(tweety) // From 4, 3
Understanding the difference between syntax (structure) and semantics (meaning) is crucial for knowledge representation.
How sentences are formed
// Syntax: P ∧ Q is well-formed
// Syntax: P ∧ is not well-formed
What sentences mean
// Semantics: P ∧ Q is true when
// both P and Q are true
Syntax tells us whether a sentence is grammatically correct, while semantics tells us whether it's true or false in a given situation.
This distinction helps us understand the difference between what we know and how we represent it.
| Aspect | Knowledge Level | Implementation Level |
|---|---|---|
| Focus | What the agent knows | How knowledge is stored |
| Language | Natural language, logic | Programming languages, data structures |
| Concerns | Correctness, completeness | Efficiency, storage, algorithms |
| Abstraction | High-level concepts | Low-level details |
| Example | "All birds can fly" | Array of rules, hash table lookup |
| Changes | Add/remove facts | Modify data structures |
Here's a complete example showing how all components work together:
// AXIOMS (Fundamental truths)
∀x (bird(x) → has_wings(x))
∀x (mammal(x) → warm_blooded(x))
∀x (fish(x) → lives_in_water(x))
// FACTS (Specific instances)
bird(tweety)
bird(robin)
mammal(whale)
fish(shark)
has_wings(tweety)
warm_blooded(whale)
lives_in_water(shark)
// RULES (Inference patterns)
∀x (bird(x) → can_fly(x))
∀x (can_fly(x) → is_animal(x))
∀x (mammal(x) → is_animal(x))
∀x (fish(x) → is_animal(x))
// INFERENCE RULES
// Modus Ponens: P → Q, P ⊢ Q
// Resolution: P ∨ Q, ¬P ∨ R ⊢ Q ∨ R
bird(tweety)bird(tweety) → has_wings(tweety)has_wings(tweety)bird(tweety) → can_fly(tweety)can_fly(tweety)can_fly(tweety) → is_animal(tweety)is_animal(tweety)Now that we understand how knowledge is structured, we'll explore how to derive new information from existing knowledge in Topic 3: Entailment and Inference.