KEMBAR78
Explain Knowledge Representation (Prolog) in AI | PDF | Knowledge Representation And Reasoning | Artificial Intelligence
0% found this document useful (0 votes)
35 views14 pages

Explain Knowledge Representation (Prolog) in AI

Uploaded by

Hamza Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views14 pages

Explain Knowledge Representation (Prolog) in AI

Uploaded by

Hamza Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
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 a fundamental
aspect of artificial intelligence (AI) that involves
structuring information about the world in a form
that a machine can understand and process.
Prolog (short for Programming in Logic) is a
prominent language used for this purpose due to
its foundation in first-order predicate logic
and its declarative nature.

• 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 excels at problems involving relationships,
pattern matching, and logical reasoning, making it
ideal for AI applications such as expert systems,
she planning.
has doll
natural language processing, and
Example: she has doll set
Tow boys have brothers if both are male and they
have same parents.
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 define what needs
to be done, not how to do it.
Logical Reasoning: Prolog uses backward
chaining to deduce answers by matching
queries with rules and facts.
Expressiveness: Can model complex
relationships, hierarchies, and constraints
easily.
Compact Syntax: Represents knowledge in
a concise manner.
4. Applications in AI
Expert Systems: Encoding domain
knowledge as rules and facts to solve
problems (e.g., medical diagnosis systems).
Natural Language Understanding: Parsing
and understanding human language.
Problem Solving: Planning and constraint
satisfaction problems.
Semantic Web: Structuring and querying
knowledge in a machine-understandable way.
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