Artificial Intelligence - UNIT 3-Topic 3-Predicate logic and logic programming
UNIT
- III
Topic
3 : Predicate Logic & Logic
Programming
Part A: Introduction
✅ What
is Logic in AI?
Logic is the foundation of reasoning in
Artificial Intelligence. It allows AI systems to make decisions, derive
conclusions, and prove facts using rules and facts.
There are two main types of logic used in AI:
- Propositional
Logic
- Predicate
Logic (First-Order Logic)
Part B: Predicate Logic (First-Order
Logic)
✅ What
is Predicate Logic?
Predicate Logic,
also called First-Order Logic (FOL), is a powerful logic system that
allows the representation of objects, properties, and relationships
among objects.
It is more expressive than Propositional Logic,
which only deals with true or false statements.
✅ Components
of Predicate Logic:
Component |
Description |
Example |
Predicate |
Represents a property or relationship |
Loves(John, Mary) → "John loves Mary" |
Variables |
Stand for objects |
x, y |
Constants |
Specific objects |
John, India |
Functions |
Map objects to objects |
Mother(John) → John's mother |
Quantifiers |
Express the number of objects for which a statement
is true |
∀
(for all), ∃
(there exists) |
✅ Common
Symbols in Predicate Logic:
Symbol |
Meaning |
∧ |
AND |
∨ |
OR |
¬ |
NOT |
→ |
IMPLIES |
↔ |
IF AND ONLY IF |
∀ |
FOR ALL (Universal Quantifier) |
∃ |
THERE EXISTS (Existential Quantifier) |
✅
Examples:
- Propositional
Logic:
- It
is raining → A
- A
is either true or false
- Predicate
Logic:
- Rains(City)
→ It is raining in a particular city
- ∀x Loves(x,
IceCream) → Everyone loves ice cream
- ∃x Student(x) ∧ Studies(x, Math) →
There exists a student who studies Math
Part C: Advantages of Predicate Logic
Advantage |
Explanation |
✅
More expressive than propositional logic |
Can represent objects and relationships |
✅
Supports reasoning and inference |
Allows deriving new knowledge |
✅
Handles universal and existential conditions |
Useful for solving real-world problems |
Part D: Logic Programming
✅
What is Logic Programming?
Logic Programming
is a type of programming where logic is used as the foundation, and
programs consist of facts and rules. It is based mainly on predicate
logic.
It is used to build AI systems that can perform
reasoning, like expert systems and intelligent agents.
✅
Most Popular Logic Programming Language:
- Prolog
(Programming in Logic)
✅ Structure
of a Logic Program
Element |
Description |
Example |
Facts |
Basic information known to be true |
father(john, david). |
Rules |
Inference based on facts |
grandfather(X, Y) :- father(X, Z), father(Z, Y). |
Queries |
Questions to be answered |
?- grandfather(john, Y). |
✅ Example
in Prolog:
% Facts
parent(john, mary).
parent(mary, tom).
% Rule
grandparent(X, Y) :- parent(X, Z), parent(Z, Y).
% Query
?- grandparent(john, tom).
% Output: true
Part E: Applications of Predicate Logic
and Logic Programming
Area |
Use Case |
Expert Systems |
Rule-based medical diagnosis or tech troubleshooting |
Natural Language Processing |
Understanding grammar and sentence structure |
Robotics |
Defining behavior through logical conditions |
Databases & Query Engines |
Representing relationships between data entities |
✅
Difference Between Propositional Logic and Predicate Logic
Feature |
Propositional Logic |
Predicate Logic |
Expressiveness |
Less expressive |
Highly expressive |
Uses variables? |
❌
No |
✅
Yes |
Can show relationships? |
❌
No |
✅
Yes |
Example |
P ∧
Q |
Loves(John, Mary) |
📝 Summary
- Predicate
Logic allows us to represent objects, their
properties, and their relationships using variables and quantifiers.
- Logic
Programming uses these logical representations
to build intelligent systems that can reason and answer queries.
- Languages
like Prolog are built on predicate logic and are widely used
in AI, NLP, and knowledge-based systems.
"Predicate logic gives AI the power to not just
know facts — but to think through them logically."
Comments
Post a Comment