8: Building a Knowledge-Based Agent

A knowledge-based agent operates by maintaining a knowledge base (KB) and using inference to make decisions. This chapter outlines the architecture, processes, and applications of such agents.

8.1 Architecture of a Knowledge-Based Agent

The architecture of a knowledge-based agent includes:

  1. Knowledge Base (KB): A repository of knowledge in the form of logical sentences.

  2. Inference Engine: A system that derives conclusions or decisions based on the KB.

8.1.1 Knowledge Base (KB)

The KB contains:

  • Facts: Statements about the world. Example: "The sky is blue."

  • Rules: Logical relationships between facts. Example: "If it is raining, the ground is wet."

8.1.2 Inference Engine

The inference engine performs reasoning by:

  1. Applying rules of logic (e.g., Modus Ponens).

  2. Deriving new facts from existing ones.

  3. Testing the truth of queries.


8.2 The Agent's Cycle

A knowledge-based agent operates in a continuous loop:

  1. Perceive: Gather information about the environment through sensors.

  2. Update KB: Add new information to the KB.

  3. Reason: Use inference to deduce actions or responses.

  4. Act: Execute actions through actuators.

Example:

  • Environment: A robot operating in a warehouse.

  • Perception: "A package is at location A."

  • KB Update: Add "Package(A)" to the KB.

  • Reasoning: "If a package is at location A, move to location A."

  • Action: The robot navigates to location A.


8.3 Knowledge Representation

8.3.1 Declarative Knowledge

Facts and rules explicitly stated in the KB. Example: "All humans are mortal: ∀x Human(x)→Mortal(x)\forall x \, Human(x) \rightarrow Mortal(x)∀xHuman(x)→Mortal(x)."

8.3.2 Procedural Knowledge

Knowledge about how to perform tasks, represented as algorithms or procedures. Example: "To move to location A, navigate along the shortest path."


8.4 Logical Inference

Logical inference is the process of deriving new knowledge from existing facts and rules.

8.4.1 Forward Chaining

  • Starts with known facts and applies rules to derive new facts. Example:

  1. Fact: "It is raining."

  2. Rule: "If it is raining, the ground is wet."

  3. Conclusion: "The ground is wet."

8.4.2 Backward Chaining

  • Starts with a goal and works backward to determine if the goal can be satisfied. Example:

  1. Goal: "Is the ground wet?"

  2. Check Rule: "If it is raining, the ground is wet."

  3. Verify Fact: "It is raining."

  4. Conclusion: "Yes, the ground is wet."


8.5 Handling Uncertainty

Not all environments provide complete or reliable information. Knowledge-based agents use probabilistic reasoning to manage uncertainty.

8.5.1 Probabilistic Logic

Incorporates probabilities into logical reasoning. Example: "There is a 70% chance that it will rain tomorrow."

8.5.2 Bayesian Networks

Graphical models that represent probabilistic relationships between variables. Example: Predicting the likelihood of a traffic jam based on weather and time of day.


8.6 Applications of Knowledge-Based Agents

8.6.1 Automated Customer Support

Agents answer queries by reasoning about a knowledge base of FAQs and support documentation.

8.6.2 Diagnostic Systems

Medical systems use knowledge bases to infer diseases based on symptoms. Example: "If the patient has a fever and cough, they may have the flu."

8.6.3 Robotics

Robots use logical reasoning to plan and execute tasks in dynamic environments. Example: A delivery robot navigating a building to deliver packages.


8.7 Building a Knowledge-Based Agent: Example

Problem: Room Cleaning Robot

  1. Environment: A robot operates in a 3x3 grid with dirty and clean tiles.

  2. Objective: Clean all tiles while minimizing energy consumption.

Steps:

  1. Knowledge Base:

    • Facts: "Tile A1 is dirty."

    • Rules: "If a tile is dirty, clean it."

  2. Inference:

    • Forward chaining: "Tile A1 is dirty → Move to A1 → Clean A1."

  3. Action:

    • The robot navigates to A1 and cleans the tile.


8.8 Summary

In this chapter, we explored:

  1. The architecture and operation of knowledge-based agents.

  2. Techniques for knowledge representation and logical inference.

  3. Applications in areas like customer support, diagnostics, and robotics.

  4. A practical example of building a room-cleaning robot.

Last updated