Knowledge Engineering in FOL
Prerequisites
🎯 Learning Objectives
- Understand the knowledge engineering process
- Model domains using categories, objects, and relations in FOL
- Represent the Wumpus world in FOL
- Grasp the basics of situation calculus for reasoning about actions
1. The Knowledge Engineering Process
Knowledge engineering is the art and science of building a knowledge base (KB) in FOL to solve problems in a given domain. The process involves:
- Identify the task: What questions must the KB answer?
- Assemble domain knowledge: Interview experts, study documentation.
- Decide on vocabulary: Choose predicates, functions, constants.
- Encode general domain axioms: Write FOL sentences capturing domain rules.
- Encode specific instances: Add facts about specific objects.
- Pose queries and debug: Test the KB, refine axioms.
2. Ontological Engineering
An ontology is a formal specification of a domain’s concepts, categories, properties, and relationships. In AI, ontologies typically include:
- Categories (classes): Dog, Vehicle, Event — represented as unary predicates.
- Instances (individuals): Fido, MyCar — represented as constants.
- Relations: PartOf, CausedBy — binary or n-ary predicates.
- Properties: Color, Weight — function symbols.
- Axioms: Rules governing the relationships.
Predicates: Parent(x,y), Male(x), Female(x), Sibling(x,y)
Functions: Mother(x), Father(x)
Axioms:
- ∀x ∀y (Parent(x,y) ∧ Female(x) → x = Mother(y))
- ∀x ∀y (Parent(x,y) ∧ Male(x) → x = Father(y))
- ∀x ∀y (Sibling(x,y) ↔ (∃z Parent(z,x) ∧ Parent(z,y) ∧ x ≠ y))
- ∀x (Male(x) ↔ ¬Female(x)) [closed-world gender]
3. The Wumpus World in FOL
The Wumpus world is a classic AI testbed. Here’s how to model it in FOL:
- Objects: Squares identified by coordinates, e.g., Sq(1,1), Sq(2,3)
- Predicates:
- At(agent, sq) — agent is at square sq
- Pit(sq) — there is a pit at sq
- Wumpus(sq) — the Wumpus is at sq
- Breeze(sq), Stench(sq), Glitter(sq) — percepts
- Adjacent(sq1, sq2) — squares are adjacent
- Safe(sq) — square is safe to visit
- ∀s (Breeze(s) ↔ ∃r (Adjacent(s,r) ∧ Pit(r)))
- ∀s (Stench(s) ↔ ∃r (Adjacent(s,r) ∧ Wumpus(r)))
- ∀s (Safe(s) ↔ ¬Pit(s) ∧ ¬Wumpus(s))
- Adjacent(Sq(x,y), Sq(x+1,y)) [simplified]
The agent uses these axioms + percepts to infer which squares are safe.
4. Situation Calculus
A formalism for reasoning about actions and change in FOL. Key ideas:
- Situations: Snapshots of the world. S0 is the initial situation.
- Actions: Represented as terms: Move(Forward), Turn(Left), Grab.
- Result function: Result(a, s) returns the situation after action a in situation s.
- Fluents: Predicates whose truth varies by situation: At(agent, sq, s), Holding(Gold, s).
- Effect axiom: At(Agent, Sq(1,1), S0) ∧ ... → At(Agent, Sq(1,2), Result(Forward, S0))
- Frame axiom: Holding(Gold, s) ∧ a ≠ Release → Holding(Gold, Result(a, s))
- Precondition axiom: Possible(Grab, s) ↔ ∃g (Gold(g) ∧ At(Agent, g, s))
The frame problem asks: how do we succinctly state what does not change when an action occurs? Naïvely, we need O(F × A) frame axioms (for F fluents and A actions). Successor-state axioms solve this by combining effect and frame axioms into a single axiom per fluent.
Summary
- Knowledge engineering translates domain expertise into FOL axioms.
- Ontologies define categories, relations, and axioms for a domain.
- The Wumpus world demonstrates FOL’s ability to model perception and inference.
- Situation calculus extends FOL to reason about actions and dynamic worlds.
- The frame problem is a key challenge; successor-state axioms address it.
References
- Russell, S. & Norvig, P. AIMA, 4th Ed. — Chapters 7.7, 10, 12
- Reiter, R. Knowledge in Action, MIT Press, 2001.