0% found this document useful (0 votes)
4 views

Explain Knowledge Representation(Prolog) in AI

Uploaded by

Hamza Rao
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Explain Knowledge Representation(Prolog) in AI

Uploaded by

Hamza Rao
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Explain Knowledge

Representation(prolog) in AI
Mam Iram
Knowledge Representation in Prolog
for AI
Knowledge representation is an important part of
artificial intelligence (AI). It means organizing
information in a way that machines can
understand and use. Prolog, which stands for
Programming in Logic, is a popular language
for this because it is based on logic and is easy to
describe what needs to be done.

• Here’s an explanation of how knowledge


representation works in Prolog and its
significance in AI:
1. What is Prolog?
Prolog is a logic programming language based
on rules and facts.
Unlike procedural languages (e.g., C++ or
Python), Prolog programs define what needs to
be solved rather than how to solve it.
It is excellent for problems involving
relationships,
 pattern matching, and logical reasoning.
Example: she has doll set
Tow boys have brothers if both are male and
has(she, doll_set).
they have same parents. has
doll
This means "she has a doll set." she
2. Components
 Prolog of primary
uses three Knowledge Representation
components in Prolog
for representing
knowledge:
 a. Facts
 Represent statements about the world that are always true.
 Explicit relationship
Symbol:
 For example: :- if
 Amna is girl , and/ conjuction
 Hair Is black ; Or /disjunction
 Syntax: predicate(arguments).
 Amna has account (1234567) has written in prolog
Account(amna,1234567).
 Amna is a teacher of all subject.
 Teacher (amna, all subject).
Code Example: jhon

prolog
parent(john, mary). mary

parent(mary, alice).
alice

Meaning: John is Mary’s parent, and Mary is


Alice’s parent.
b. Rules
Represent conditional statements or relationships.
Syntax: Head :- Body.
Example:
prolog
X: ahmed
Y: Ali
Z: zain
X: ahmed Z: zain Y: Ali

grandparent(X, Y) :- parent(X, Z), parent(Z, Y).


Meaning: X is a grandparent of Y if X is a parent of Z and Z is a parent of Y.
Example:
 Mega is a daughter of sham if sham is a father of mega.
 X is father of Y if X is a parent of Y and X is male.
prolog
father(X,Y):- parent(X,Y),male(X).
c. Queries
Allow the system to infer information from facts and rules.
Syntax: ?- query.
Example:
prolog
?- grandparent(john, alice).
The system will return true if the query is satisfied based on facts and rules, or false
otherwise.
Example:
Mega is jhon?
 Is pizza a food?
?-food(pizza)
 Which food is meal and lunch

?-meal(X);lunch(X).

X:- Y;Z
X:- Y
X:- Z
3. Advantages of Prolog for Knowledge Representation
•Declarative Nature: You just explain what to do, not how to do
it.
•Logical Reasoning: Prolog finds answers by matching queries
with rules and facts.
•Expressiveness: Easily handles complex relationships and
structures.
•Compact Syntax: Knowledge is written in a short and clear
way.
4. Applications in AI
•Expert Systems: Use rules and facts to solve
problems, like medical diagnosis systems.
•Natural Language Understanding: Helps in
understanding and processing human language.
•Problem Solving: Handles planning and solving
constraint-based problems.
•Semantic Web: Organizes and queries
knowledge so machines can understand it.
5.

Example: Family Relationship Knowledge Base
Here’s a simple Prolog program for representing family relationships:
 prolog
 % Facts parent(john, mary).
 parent(mary, alice).
 parent(mary, tom).
 parent(alice, sarah).

 % Rules
 grandparent(X, Y) :- parent(X, Z), parent(Z, Y).
 sibling(X, Y) :- parent(Z, X), parent(Z, Y), X \= Y.

 % Queries
 ?- grandparent(john, sarah). % true
 ?- sibling(alice, tom). % true
 ?- parent(john, tom). % false
6. Challenges of Knowledge Representation in Prolog
Scalability: Handling large-scale knowledge
bases can be challenging.
Uncertainty: Prolog doesn’t handle
probabilistic reasoning directly.
Ambiguity: Representing vague or
ambiguous knowledge requires extensions or
workarounds.
Conclusion
Prolog provides a robust framework for
representing and reasoning about knowledge
in AI. Its logical structure allows developers
to focus on the semantics of the problem
rather than the implementation, making it a
powerful tool for building intelligent systems.
Any Question?
Thank You

You might also like