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:
- Stores knowledge in a formal way using logic (in a Knowledge Base).
- Applies inference rules to derive new information from existing knowledge.
- Acts or makes decisions based on what it has logically inferred.
Components of a Logical Agent
Component | Function |
---|---|
Knowledge Base (KB) | A collection of facts and rules written in logical form. |
Inference Engine | Applies logic rules to derive new knowledge from existing knowledge. |
Perception/Input | The agent receives facts or observations from the environment. |
Action/Decision | Based 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:
Situation | Logical Representation | Result |
---|---|---|
If the alarm is sounding, there is a fire. | Alarm → Fire | |
The alarm is sounding. | Alarm | Agent infers: Fire |
The agent may decide to:
Alert emergency services or
Evacuate the building
Why Use Logical Agents?
Advantage | Explanation |
---|---|
Explainability | Reasoning is transparent and traceable. |
Certainty | Works well when facts are known and logic is clear. |
Formal Framework | Can be mathematically proved to be correct. |
Limitations of Logical Agents
Limitation | Why It’s a Problem |
---|---|
Cannot handle uncertainty | Logic is binary: true or false — no room for “probably” or “maybe”. |
Rigid rules | Needs exact matches; can’t generalize easily. |
Scalability | Becomes complex with large rule sets or real-world environments. |
Summary
Term | Explanation |
---|---|
Logical Agent | AI system that uses logic to make decisions |
Knowledge Base (KB) | Stores facts and rules in logical form |
Inference | Derives new facts using rules of logic |
Example | If 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
Symbol | Name | Meaning | Example |
---|---|---|---|
¬ | NOT (Negation) | True becomes False, False becomes True | ¬P: “It is NOT raining” |
∧ | AND (Conjunction) | True if both are true | P ∧ Q: “It’s raining and the ground is wet” |
∨ | OR (Disjunction) | True if at least one is true | P ∨ Q: “It’s raining or the ground is wet” |
→ | IMPLIES (Conditional) | If P is true, then Q must be true | P → Q: “If it rains, the ground is wet” |
↔ | IFF (Biconditional) | True when both are either true or false | P ↔ 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 Statement | Meaning in English |
---|---|
P → Q | If it is raining, then the ground is wet |
¬P | It is not raining |
P ∧ Q | It is raining and the ground is wet |
P ∨ Q | It is raining or the ground is wet |
P ↔ Q | It 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)
P | Q | P → Q | Meaning |
---|---|---|---|
T | T | T | There is no contradiction if it is raining the ground is wet. |
T | F | F | It rains but ground not wet → contradiction |
F | T | T | It doesn’t rain, but ground is wet → still okay |
F | F | T | It 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
P | Q | ¬P | P ∧ Q | P ∨ Q | P ↔ Q |
---|---|---|---|---|---|
T | T | F | T | T | T |
T | F | F | F | T | F |
F | T | T | F | T | F |
F | F | T | F | F | T |
Why Use Propositional Logic in AI?
Reason | Explanation |
---|---|
Formal reasoning | AI can apply mathematical inference rules |
Rule creation | IF-THEN rules for expert systems and agents |
Transparency | Logic-based reasoning is clear and explainable |
Foundation for higher logic | Forms the basis for First-Order Logic (FOL) and knowledge representation |
Limitations of Propositional Logic
Limitation | Example |
---|---|
Cannot express relationships | Like “Ali is the father of Sara” |
Cannot use variables | Like “All humans are mortal” |
Cannot handle uncertainty | Real-world statements often aren’t just true/false |
We employ Probabilistic Logic or First-order logic in those situations.
Summary
Concept | Explanation |
---|---|
Proposition | A statement that is either true or false |
Connectives | NOT (¬), AND (∧), OR (∨), IMPLIES (→), IFF (↔) |
Syntax | How to build valid logical expressions |
Semantics | Meaning of expressions using truth tables |
Use in AI | Basis for reasoning in expert systems, agents |