CSE-41XX
CS-4101 AI

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

  1. Knowledge Base (KB): A collection of sentences expressed in a formal representation language. Facts, rules, and relationships are written out directly (e.g., RainingWet(Ground)\text{Raining} \Rightarrow \text{Wet}(\text{Ground})) rather than buried implicitly in millions of numeric weights. The knowledge is visible, human-readable, and easily inspected or updated.
  2. 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 (True\text{True} or False\text{False}). In contrast, Fuzzy Logic extends classical logic by allowing degrees of truth represented as continuous values between 00 and 11.
  • 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 True\text{True} or False\text{False}) and combines them using logical connectives.

Connectives and Compound Sentences

There are five fundamental types of compound sentences in propositional logic:

  1. Negation (NOT): ¬P\neg P (e.g., "It is not raining" ¬Raining\equiv \neg \text{Raining})
  2. Conjunction (AND): PQP \land Q (e.g., "It is raining and I have an umbrella" RainingUmbrella\equiv \text{Raining} \land \text{Umbrella})
  3. Disjunction (OR): PQP \lor Q (e.g., "It is raining or it is snowing" RainingSnowing\equiv \text{Raining} \lor \text{Snowing})
  4. Implication (IF-THEN): PQP \Rightarrow Q (Material Implication: PP is the antecedent, QQ is the consequent. False only when PP is true and QQ is false):

PQ¬PQP \Rightarrow Q \equiv \neg P \lor Q

  1. Biconditional (IFF): PQP \Leftrightarrow Q (True if and only if both PP and QQ have the exact same truth value):

PQ(PQ)(QP)(¬PQ)(¬QP)P \Leftrightarrow Q \equiv (P \Rightarrow Q) \land (Q \Rightarrow P) \equiv (\neg P \lor Q) \land (\neg Q \lor P)

Truth Tables for Implication and Biconditional

PPQQPQP \Rightarrow QPQP \Leftrightarrow Q
1111
1000
0110
0011

Logical Equivalences

Logical equivalences allow us to rearrange and simplify logical expressions:

Rule NameEquivalence Formula
Double Negation¬(¬P)P\neg(\neg P) \equiv P
Commutative LawsPQQPP \lor Q \equiv Q \lor P
PQQPP \land Q \equiv Q \land P
Associative Laws(PQ)RP(QR)(P \lor Q) \lor R \equiv P \lor (Q \lor R)
(PQ)RP(QR)(P \land Q) \land R \equiv P \land (Q \land R)
Distributive LawsP(QR)(PQ)(PR)P \lor (Q \land R) \equiv (P \lor Q) \land (P \lor R)
P(QR)(PQ)(PR)P \land (Q \lor R) \equiv (P \land Q) \lor (P \land R)
De Morgan's Laws¬(PQ)¬P¬Q\neg(P \land Q) \equiv \neg P \lor \neg Q
¬(PQ)¬P¬Q\neg(P \lor Q) \equiv \neg P \land \neg Q
Implication EliminationPQ¬PQP \Rightarrow Q \equiv \neg P \lor Q
Biconditional EliminationPQ(¬PQ)(¬QP)P \Leftrightarrow Q \equiv (\neg P \lor Q) \land (\neg Q \lor P)

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 TypeExample StatementsInternal StructureRepresentational Power
Propositional Logictoday_is_wet\text{today\_is\_wet}, john_likes_apples\text{john\_likes\_apples}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)IsWet(Today)\text{IsWet}(\text{Today}), Likes(John,Apples)\text{Likes}(\text{John}, \text{Apples})Has internal structure: Predicates are applied to terms/objects.Can express properties of objects, relationships, and generalizations.

Elements of First-Order Logic

  1. Constants: Represent specific objects in the world (e.g., John\text{John}, Apples\text{Apples}, Socrates\text{Socrates}).
  2. Predicates: Represent properties of objects or relationships between them; evaluate to True or False (e.g., IsWet(x)\text{IsWet}(x), Likes(John,Apples)\text{Likes}(\text{John}, \text{Apples})).
  3. Functions: Map an object or tuple of objects to another object (e.g., fruit_of(AppleTree)\text{fruit\_of}(\text{AppleTree}), Father(John)\text{Father}(\text{John})).
  4. Variables: Lowercase placeholders representing generic domain objects (e.g., xx, yy, zz).
  5. 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 (\forall)

Expresses that a sentence holds true for all objects in the domain ("For all...", "Every...").

  • Example 1: "All dogs like bones."

x(Dog(x)Likes(x,Bones))\forall x (\text{Dog}(x) \Rightarrow \text{Likes}(x, \text{Bones}))

  • Example 2: "Anything with a beak and feathers is a bird."

x(HasBeak(x)HasFeathers(x)Bird(x))\forall x (\text{HasBeak}(x) \land \text{HasFeathers}(x) \Rightarrow \text{Bird}(x))

  • Example 3: "All men are mortal."

x(Man(x)Mortal(x))\forall x (\text{Man}(x) \Rightarrow \text{Mortal}(x))

2. Existential Quantifier (\exists)

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."

xLikes(x,Liver)\exists x \text{Likes}(x, \text{Liver})

  • Example 2: "Mary owns a coat."

x(Owns(Mary,x)Coat(x))\exists x (\text{Owns}(\text{Mary}, x) \land \text{Coat}(x))


Key Quantifier Rules and Nuances

Quantifier Order Matters

The order of quantifiers significantly alters statement semantics:

  • xyLoves(x,y)\forall x \exists y \text{Loves}(x, y)
    • Meaning: "For every person xx, there exists a person yy whom xx loves." (Everyone loves someone.)
  • xyLoves(x,y)\exists x \forall y \text{Loves}(x, y)
    • Meaning: "There exists a person xx who loves every person yy." (There is one universally loving person.)

Translating Complex Domain Statements

Consider the sentence: "Every rose has a thorn."

  • English Breakdown: For all xx, if xx is a rose, then there exists some yy such that yy is a thorn and xx has yy.
  • FOL Representation:

x(Rose(x)y(Has(x,y)Thorn(y)))\forall x (\text{Rose}(x) \Rightarrow \exists y (\text{Has}(x, y) \land \text{Thorn}(y)))

Logical Inference Example in FOL

Given the general rule:

x(King(x)Greedy(x)Evil(x))\forall x (\text{King}(x) \land \text{Greedy}(x) \Rightarrow \text{Evil}(x))

Inference in FOL allows substituting any constant term or function for variable xx:

  • King(John)Greedy(John)Evil(John)\text{King}(\text{John}) \land \text{Greedy}(\text{John}) \Rightarrow \text{Evil}(\text{John})
  • King(Richard)Greedy(Richard)Evil(Richard)\text{King}(\text{Richard}) \land \text{Greedy}(\text{Richard}) \Rightarrow \text{Evil}(\text{Richard})
  • King(Father(John))Greedy(Father(John))Evil(Father(John))\text{King}(\text{Father}(\text{John})) \land \text{Greedy}(\text{Father}(\text{John})) \Rightarrow \text{Evil}(\text{Father}(\text{John}))

On this page