Lecture 09.1: Knowledge-Based Agents and Logic
Exploring how AI agents use explicit knowledge representation, Propositional Logic, and First-Order Logic to reason about the world.
Early AI research was dominated by two contrasting paradigms: connectionist models (such as early neural networks) and symbolic reasoning. In the 1970s and 1980s, pioneering researchers like Marvin Minsky helped shift the focus of AI toward symbolic reasoning and explicit knowledge representation.
Historical Context & The Evolution of Symbolic AI
- "Perceptrons" (1969): Marvin Minsky and Seymour Papert co-authored Perceptrons, an influential book that mathematically demonstrated the severe limitations of early single-layer neural networks (such as their inability to compute the exclusive-OR function). This critique triggered a critical turning point in AI research, shifting resources away from simple sub-symbolic networks toward explicit, symbolic knowledge representation.
- Introducing "Frames" (1970s): Recognizing that pure formal logic was too rigid and simple networks too unstructured to capture complex human knowledge, Minsky proposed Frames as a model for structured, contextual knowledge.
- Key Features of Frames: Hierarchical organization of information, slots for object properties, default values, and inheritance capabilities.
- Legacy: Concepts such as classes, objects, properties, inheritance, and encapsulation in modern programming languages (Smalltalk, C++, Java) directly reflect this legacy.
- Knowledge Representation in the 1980s: Early AI systems by Allen Newell (such as List Processing, Logic Theorist, and General Problem Solver) laid the groundwork for formal reasoning. By the 1980s, Knowledge Representation emerged as an explicit subfield of AI focused on building systems that store, manipulate, and reason over structured facts.
Knowledge-Based Agents
A Knowledge-Based Agent is an intelligent AI system that relies on an explicit representation of knowledge to reason, make decisions, and plan actions.
Human intelligence goes beyond pure reflexes or simple stimulus-response reactions. Humans make complex choices using internal mental representations of the world. Knowledge-based agents mirror this approach.
Components of a Knowledge-Based Agent
- Knowledge Base (KB): A collection of sentences expressed in a formal representation language. Facts, rules, and relationships are written out directly (e.g., ) rather than buried implicitly in millions of numeric weights. The knowledge is visible, human-readable, and easily inspected or updated.
- Inference Engine: The reasoning component that applies logical rules to the stored KB to derive new facts, answer queries, or decide on actions.
What is a Logic?
A logic is a formal language governed by concrete mathematical rules of syntax and semantics.
- No Ambiguity: Unlike natural languages (e.g., English), logical statements have exact, unambiguous meanings.
- Classical Logic vs. Fuzzy Logic: Classical logic operates on Boolean truth values ( or ). In contrast, Fuzzy Logic extends classical logic by allowing degrees of truth represented as continuous values between and .
- Logic vs. Logical Reasoning: A logic is the representation language itself, whereas logical reasoning is the algorithmic process executed by an inference engine using that logic.
Propositional Logic
Propositional logic is the simplest formal logical language. It deals with atomic propositions (indivisible statements that evaluate to or ) and combines them using logical connectives.
Connectives and Compound Sentences
There are five fundamental types of compound sentences in propositional logic:
- Negation (NOT): (e.g., "It is not raining" )
- Conjunction (AND): (e.g., "It is raining and I have an umbrella" )
- Disjunction (OR): (e.g., "It is raining or it is snowing" )
- Implication (IF-THEN): (Material Implication: is the antecedent, is the consequent. False only when is true and is false):
- Biconditional (IFF): (True if and only if both and have the exact same truth value):
Truth Tables for Implication and Biconditional
| 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 0 | 0 | 1 | 1 |
Logical Equivalences
Logical equivalences allow us to rearrange and simplify logical expressions:
| Rule Name | Equivalence Formula |
|---|---|
| Double Negation | |
| Commutative Laws | |
| Associative Laws | |
| Distributive Laws | |
| De Morgan's Laws | |
| Implication Elimination | |
| Biconditional Elimination |
Limitations of Propositional Logic
While propositional logic is easy to automate, it lacks expressiveness. Because atoms have no internal structure, propositional logic cannot express properties of objects, relationships between objects, or general statements using quantifiers ("for all", "there exists").
[!NOTE] Expressiveness Benchmark (Chess Rules):
- In Propositional Logic, fully encoding the rules of chess requires 100,000 pages of logic.
- In First-Order Logic, the exact same rules fit onto 1 page.
First-Order Logic (FOL)
First-Order Logic (FOL) (also called Predicate Logic) extends propositional logic by introducing objects, properties, relationships, functions, and quantifiers.
Comparing Propositional Logic and Predicate Logic
| Logic Type | Example Statements | Internal Structure | Representational Power |
|---|---|---|---|
| Propositional Logic | , | No internal structure: Each statement is a single indivisible atom (Boolean true/false). | Cannot represent who likes what or generalize over categories of objects. |
| Predicate Logic (FOL) | , | Has internal structure: Predicates are applied to terms/objects. | Can express properties of objects, relationships, and generalizations. |
Elements of First-Order Logic
- Constants: Represent specific objects in the world (e.g., , , ).
- Predicates: Represent properties of objects or relationships between them; evaluate to True or False (e.g., , ).
- Functions: Map an object or tuple of objects to another object (e.g., , ).
- Variables: Lowercase placeholders representing generic domain objects (e.g., , , ).
- Quantifiers: Allow generalized statements over domain elements.
Quantifiers in FOL
FOL uses two quantifiers to express general rules over sets of objects:
1. Universal Quantifier ()
Expresses that a sentence holds true for all objects in the domain ("For all...", "Every...").
- Example 1: "All dogs like bones."
- Example 2: "Anything with a beak and feathers is a bird."
- Example 3: "All men are mortal."
2. Existential Quantifier ()
Expresses that a sentence holds true for at least one object in the domain ("There exists...", "There is some...").
- Example 1: "There is someone who likes liver."
- Example 2: "Mary owns a coat."
Key Quantifier Rules and Nuances
Quantifier Order Matters
The order of quantifiers significantly alters statement semantics:
-
- Meaning: "For every person , there exists a person whom loves." (Everyone loves someone.)
-
- Meaning: "There exists a person who loves every person ." (There is one universally loving person.)
Translating Complex Domain Statements
Consider the sentence: "Every rose has a thorn."
- English Breakdown: For all , if is a rose, then there exists some such that is a thorn and has .
- FOL Representation:
Logical Inference Example in FOL
Given the general rule:
Inference in FOL allows substituting any constant term or function for variable :
Lecture 08.2: Fuzzy Expert Systems
Handling vagueness and ambiguity using Fuzzy Logic, membership functions, and the four steps of Fuzzy Inference.
Lecture 09.2: CNF Conversion and Resolution
How to convert First-Order Logic into Conjunctive Normal Form (CNF) and use Resolution graphs to prove theorems.