L # 3.7 & 3.8 – Logical Agents in Artificial Intelligence – Propositional Logic in Artificial Intelligence – Coding With Clicks

2. Logical Agents

A logical agent is a kind of artificial intelligence system that bases decisions or inferences from known facts on logic.

What Makes an Agent “Logical”?

A logical agent:

  1. Stores knowledge in a formal way using logic (in a Knowledge Base).
  2. Applies inference rules to derive new information from existing knowledge.
  3. Acts or makes decisions based on what it has logically inferred.

Components of a Logical Agent

ComponentFunction
Knowledge Base (KB)A collection of facts and rules written in logical form.
Inference EngineApplies logic rules to derive new knowledge from existing knowledge.
Perception/InputThe agent receives facts or observations from the environment.
Action/DecisionBased on logical conclusions, the agent takes an action or makes a choice.

1. Knowledge Base (KB)

  • A Knowledge Base is like the brain of the logical agent.
  • It contains facts and rules represented in logical sentences.
  • The following sentences can be found in:
    • P → Q is an example of propositional logic.
    • ∀x Human(x) → Mortal(x) is an example of First-order logic.

Example:

1. If it is raining, the ground is wet.      (Raining → WetGround)
2. It is raining. (Raining)
⟹ The ground is wet. (WetGround)

This is called Modus Ponens, a basic inference rule:

B must also be true if A → B and A is true.

2. Inference Mechanism

The agent uses logical inference to:

  • Check whether something is true or false.
  • Derive new facts from known facts and rules.

Common inference rules:

  • Modus Ponens states that B must be concluded if A → B and A.
  • According to Modus Tollens, ¬A must be concluded if A → B and ¬B.
  • Resolution: In propositional logic, it is used to demonstrate unsatisfiability.
  • Unification: In first-order logic, matches patterns in predicates.

3. Decision Making

After deriving conclusions from its knowledge base, the agent can:

  • Answer questions (“Is the ground wet?”)
  • Choose actions (“Should I carry an umbrella?”)
  • Update its knowledge (add new facts, remove false ones)

Example Scenario:

SituationLogical RepresentationResult
If the alarm is sounding, there is a fire.Alarm → Fire
The alarm is sounding.AlarmAgent infers: Fire

The agent may decide to:
Alert emergency services or
Evacuate the building

Why Use Logical Agents?

AdvantageExplanation
ExplainabilityReasoning is transparent and traceable.
CertaintyWorks well when facts are known and logic is clear.
Formal FrameworkCan be mathematically proved to be correct.

Limitations of Logical Agents

LimitationWhy It’s a Problem
Cannot handle uncertaintyLogic is binary: true or false — no room for “probably” or “maybe”.
Rigid rulesNeeds exact matches; can’t generalize easily.
ScalabilityBecomes complex with large rule sets or real-world environments.

Summary

TermExplanation
Logical AgentAI system that uses logic to make decisions
Knowledge Base (KB)Stores facts and rules in logical form
InferenceDerives new facts using rules of logic
ExampleIf raining → wet ground; it’s raining ⇒ ground is wet

Real-Life Applications

  • Rule-Based Expert Systems (such as tools for medical diagnosis)
  • Legal Reasoning Systems
  • Game AI (using logic to determine legal moves)
  • Autonomous agents in controlled environments

3. Propositional Logic (PL)

(Also known as Boolean Logic)

What is Propositional Logic?

A subfield of logic known as propositional logic (PL) deals with straightforward claims that can only be true (T) or false (F).
It is used in AI to:

  • Represent knowledge formally
  • Build logical rules
  • Enable machines to infer conclusions using logical reasoning

Key Idea:

A proposition is a declarative sentence that is either true or false — not both.

Examples:

  • “It is raining” → True or False
  • “What time is it?” → Not a proposition (question)
  • “Go outside!” → Not a proposition (command)

Syntax of Propositional Logic

Syntax tells us how to write valid logical expressions in PL.

1. Propositional Symbols

These are usually uppercase letters:
P, Q, R, S, A, B…
Each represents a simple statement.

Example:

  • P: “It is raining”
  • Q: “The ground is wet”

2. Operators with Logical Connectives

SymbolNameMeaningExample
¬NOT (Negation)True becomes False, False becomes True¬P: “It is NOT raining”
AND (Conjunction)True if both are trueP ∧ Q: “It’s raining and the ground is wet”
OR (Disjunction)True if at least one is trueP ∨ Q: “It’s raining or the ground is wet”
IMPLIES (Conditional)If P is true, then Q must be trueP → Q: “If it rains, the ground is wet”
IFF (Biconditional)True when both are either true or falseP ↔ Q: “It rains if and only if the ground is wet”

Propositional logic statement examples

  • P: “It is raining”
  • Q: “The ground is wet”
Logical StatementMeaning in English
P → QIf it is raining, then the ground is wet
¬PIt is not raining
P ∧ QIt is raining and the ground is wet
P ∨ QIt is raining or the ground is wet
P ↔ QIt rains if and only if the ground is wet

Propositional Logic Semantics

Semantics is about the meaning or truth value of logical statements.
Truth values:

  • T = True
  • F = False

We use truth tables to evaluate compound statements.

P → Q Truth Table (Implication)

PQP → QMeaning
TTTThere is no contradiction if it is raining the ground is wet.
TFFIt rains but ground not wet → contradiction
FTTIt doesn’t rain, but ground is wet → still okay
FFTIt doesn’t rain, ground not wet → also okay

In logic, “P → Q” is false only when P is true and Q is false.

Truth Table for Basic Connectives

PQ¬PP ∧ QP ∨ QP ↔ Q
TTFTTT
TFFFTF
FTTFTF
FFTFFT

Why Use Propositional Logic in AI?

ReasonExplanation
Formal reasoningAI can apply mathematical inference rules
Rule creationIF-THEN rules for expert systems and agents
TransparencyLogic-based reasoning is clear and explainable
Foundation for higher logicForms the basis for First-Order Logic (FOL) and knowledge representation

Limitations of Propositional Logic

LimitationExample
Cannot express relationshipsLike “Ali is the father of Sara”
Cannot use variablesLike “All humans are mortal”
Cannot handle uncertaintyReal-world statements often aren’t just true/false

We employ Probabilistic Logic or First-order logic in those situations.

Summary

ConceptExplanation
PropositionA statement that is either true or false
ConnectivesNOT (¬), AND (∧), OR (∨), IMPLIES (→), IFF (↔)
SyntaxHow to build valid logical expressions
SemanticsMeaning of expressions using truth tables
Use in AIBasis for reasoning in expert systems, agents

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top