You are on page 1of 65

KNOWLEDGE REPRESENTATION

About Knowledge
• Knowledge representation and reasoning (KR, KRR) is the part of
Artificial intelligence which concerned with AI agents thinking and
how thinking contributes to intelligent behavior of agents.
• It is responsible for representing information about the real world
so that a computer can understand and can utilize this knowledge to
solve the complex real world problems such as diagnosis a medical
condition or communicating with humans in natural language.
• It is also a way which describes how we can represent knowledge in
artificial intelligence. Knowledge representation is not just storing
data into some database, but it also enables an intelligent machine
to learn from that knowledge and experiences so that it can behave
intelligently like a human.
Environment
Agent
Then If temp is above 100 cel
trigger Humidity
alarm Carbon monoxide in air
Carbon dioxide

We have some knowledge about the environment, we use this knowledge to


train our agent to make intelligent decision while interaction with the
environment.
Gives information about a certain
disease

Domain
Expert Knowledge Knowledge
Engineer Base
Doc
Specialist Anmol System

Test 1 Test 2 Test 3 Test 4 Test 5 Result


Rep1 %age %age %age %age %age Yes
Rep2 %age %age %age %age %age No

Construct a knowledge graph or database or whatever to


represent information into a useful form
Machine Learning
• Divide into training set and testing set
• Training 80% Testing 20%
• Training set train the data model
• Check the output on testing set
• Check accuracy and remove the error,
• Make prediction
What to represent
• Object: All the facts about objects in our world domain. E.g., Guitars
contains strings, trumpets are brass instruments.
• Events: Events are the actions which occur in our world.
• Performance: It describe behavior which involves knowledge about
how to do things.
• Meta-knowledge: It is knowledge about what we know.
• Facts: Facts are the truths about the real world and what we
represent.
• Knowledge-Base: The central component of the knowledge-based
agents is the knowledge base. It is represented as KB. The
Knowledgebase is a group of the Sentences (Here, sentences are used
as a technical term and not identical with the English language).
Types of Knowledge
Declarative Knowledge
• Declarative knowledge is to know about
something.
• It includes concepts, facts, and objects.
• It is also called descriptive knowledge and
expressed in declarative sentences.
• It is simpler than procedural language.
Procedural Knowledge
• It is also known as imperative knowledge.
• Procedural knowledge is a type of knowledge
which is responsible for knowing how to do
something.
• It can be directly applied to any task.
• It includes rules, strategies, procedures, agendas,
etc.
• Procedural knowledge depends on the task on
which it can be applied.
Meta-knowledge
Knowledge about the other types of knowledge
is called Meta-knowledge.

Gives further knowledge about my existing knowledge.


Heuristic knowledge
• Heuristic knowledge is representing
knowledge of some experts in a filed or
subject.
• Heuristic knowledge is rules of thumb based
on previous experiences, awareness of
approaches, and which are good to work but
not guaranteed.
Structural knowledge
• Structural knowledge is basic knowledge to
problem-solving.
• It describes relationships between various
concepts such as kind of, part of, and grouping
of something.
• It describes the relationship that exists
between concepts or objects
HOW KNOWLEDGE WORKS IN AI

Artificial
Senses Intelligent Knowledge
System

Action
KNOWLEDGE CYCLE IN ARTIFICIAL
INTELLIGENCE
• Perception
• Learning
• Knowledge Representation and Reasoning
• Planning
• Execution
Learning

Perception

Knowledge Planning
Representation

Execution
Types of Knowledge Representation

• Logics
Types of Logics
• Propositional Logic
• Predicate Logic
Logics
• Whether the given statement is true or false
 5+3 = 9 (False)
 Sun rises in the east. (True)
Knowledge Representation
• I is going to school. (Wrong)
• I are going to school. (Wrong)
• I am going to school. ( Correct Knowledge)

True False
Knowledge Representation
• I went to Bus by Delhi. (Logically Incorrect)
• I went to Delhi by Bus. (Logically Correct)

True False
Syntax vs. Semantic
I is going to school. I went to Bus by Delhi.
I are going to school.
Grammatically Correct
Grammatically Incorrect
But Logically Incorrect
Logically Correct
Semantic Error
Syntax Error
Structure of a Sentence
• <Sentence>  <Subject><Predicate>
• <Subject>  <Noun><Noun-Phrase>
• <Predicate>  <Verb><Noun-Phrase>
• < Noun-Phrase >  <Adjective><Noun>
• <Adjectives>  Smart | Shy | Intelligent
• <Articles>  A | An | The
Machine Processing
• <Sentence>  <Subject><Predicate>
• <Noun>  Ram | Sham | Mohan | The Boy
• <Adjective>  Intelligent | shy | dull
• <Article>  A | An | The
Sentence Processing
<Sentence>  <Subject><Predicate>
 < Noun-Phrase> <Predicate>
 <Article><Noun><Predicate>
 The <Noun> <Predicate>
The boy <Predicate>
 The boy <Verb><adjective>
 The boy is very <adjective>
 The boy is very intelligent
Proposition
A proposition is any given statement. This can be ether true
or false, but can`t be partially true or partially false.

 The tea is very hot.


 12- 2 = 10
 The sun rises from the west.
 He is older than his father.
 Delhi is capital of India.

 It is most likely that we will see sun tomorrow.


Proposition Logic
• It tells whether the given statement is true or
false. It will never say that statement will be
partially true or false.
• The operations:
• ^ And operation
• v Or operation
• ~ Not Operation

AND Operator
And operator signifies when both the statements given in the logic are true.

• If value of x is 5
• And value of y is 4
• Then the value of z will be 9

x Y Z=9
3 5 False
5 4 True
2 5 False
5 3 False
2 4 False
Example 2
• If there are no clouds today and the
temperature is above 24 degree C. Then it will
be sunny tomorrow.

Clouds Temp Sunny tomorrow?


Yes (F) 29 (T) False
Yes (F) 15 (F) False
NO (T) 15 (F) False
NO (T) 29 (T) True
OR Operator
This operator signifies if any one of the given statement is true then the
result will be true.

• He will pass the exam only if you work hard or


cheat.
Work hard Cheat Pass
Yes (T) Yes (T) Yes (T)
NO (F) NO (F) No(F)
NO Yes Yes (T)
Yes NO yes (T)
NOT Operator
It is a contradictory operator. It gives the opposite result
to the given statement
• If there is no direct UV radiations person will
survive.

UV radiation Survival
Yes (T) Not Possible (F)
NO (F) Possible (T)
Yes (T) Not Possible (F)
ADVANTAGES OF USING LOGIC?
• Logic is the basics of programming.
• It helps us in reasoning.
DISADVANTAGES?
• Logics have certain restrictions and it
challenging to work with.
Semantic Network
Semantic networks are alternative of predicate logic for knowledge
representation. In Semantic networks, we can represent our knowledge in the
form of graphical networks. This network consists of nodes representing
objects and arcs which describe the relationship between those objects.
Semantic networks can categorize the object in different forms and can also
link those objects. Semantic networks are easy to understand and can be easily
extended.

This representation consist of mainly two types of relations:


– IS-A relation (Inheritance)
– Kind-of-relation

Example: Following are some statements which we need to represent in the


form of nodes and arcs.
Example
• Raman is a student
• Raman is in B.Tech 7
• Raman studies Big Data
• Raman studies at GNA
• All students in GNA study artificial intelligence
Semantic Network
 Raman is a student
 Raman is in B.Tech 7 Raman
 Raman studies Big Data
 Raman studies at GNA Is-A
 All students in GNA study
artificial intelligence
Student

Is-A

B.Tech GNA
7

Big
Data GNA
Example Mouse
Cat
• Tom is a cat
Is-A
• Tom is mammal
Is-A
• Tom is owned by Jerry
• Tom is brown in color TOM Mammal
• All mammals are animals
Is-Owned
Is-A

Is-Color
Jerry
Animals

Brown
Semantic Network vs Logic
LOGIC
Tom is a cat and cat is mammal
and tom has two eyes.

All mammals have two eyes

Does Tom has 2 eyes?


T
Advantages of Semantic Network
• Semantic networks are a natural
representation of knowledge.
• Semantic networks convey meaning in a
transparent manner.
• These networks are simple and easily
understandable.
Disadvantages of Semantic Network
• Semantic networks take more computational time at runtime as we need
to traverse the complete network tree to answer some questions. It
might be possible in the worst case scenario that after traversing the
entire tree, we find that the solution does not exist in this network.
• Semantic networks try to model human-like memory (Which has 1015
neurons and links) to store the information, but in practice, it is not
possible to build such a vast semantic network.
• These types of representations are inadequate as they do not have any
equivalent quantifier, e.g., for all, for some, none, etc.
• Semantic networks do not have any standard definition for the link
names.
• These networks are not intelligent and depend on the creator of the
system.
Frames
• A frame is a record like structure which consists of a collection of attributes and its
values to describe an entity in the world. Frames are the AI data structure which divides
knowledge into substructures by representing stereotypes situations. It consists of a
collection of slots and slot values. These slots may be of any type and sizes. Slots have
names and values which are called facets.
• Facets: The various aspects of a slot is known as Facets. Facets are features of frames
which enable us to put constraints on the frames. Example: IF-NEEDED facts are called
when data of any particular slot is needed. A frame may consist of any number of slots,
and a slot may include any number of facets and facets may have any number of values.
A frame is also known as slot-filter knowledge representation in artificial intelligence.
• Frames are derived from semantic networks and later evolved into our modern-day
classes and objects. A single frame is not much useful. Frames system consist of a
collection of frames which are connected. In the frame, knowledge about an object or
event can be stored together in the knowledge base. The frame is a type of technology
which is widely used in various applications including Natural language processing and
machine visions.
Frame Example
Example
Make a frame for an entity, Peter. Peter is an
engineer as a profession, and his age is 25, he
lives in city London, and the country is England.
Adv. Of using frames
• The frame knowledge representation makes the
programming easier by grouping the related data.
• The frame representation is comparably flexible and
used by many applications in AI.
• It is very easy to add slots for new attribute and
relations.
• It is easy to include default data and to search for
missing values.
• Frame representation is easy to understand and
visualize.
Disadvantages of Using frames
• In frame system inference mechanism is not
be easily processed.
• Inference mechanism cannot be smoothly
proceeded by frame representation.
• Frame representation has a much generalized
approach.
Production Rules
• Production rules system consist of (condition, action) pairs which mean, "If condition
then action". It has mainly three parts:
• The set of production rules
– Working Memory
– The recognize-act-cycle
• In production rules agent checks for the condition and if the condition exists then
production rule fires and corresponding action is carried out. The condition part of the
rule determines which rule may be applied to a problem. And the action part carries out
the associated problem-solving steps. This complete process is called a recognize-act
cycle.
• The working memory contains the description of the current state of problems-solving
and rule can write knowledge to the working memory. This knowledge match and may
fire other rules.
• If there is a new situation (state) generates, then multiple production rules will be fired
together, this is called conflict set. In this situation, the agent needs to select a rule from
these sets, and it is called a conflict resolution.
Example
• IF (at bus stop AND bus arrives) THEN action
(get into the bus)
• IF (on the bus AND paid AND empty seat)
THEN action (sit down).
• IF (on bus AND unpaid) THEN action (pay
charges).
• IF (bus arrives at destination) THEN action (get
down from the bus).
Advantages of Production Rules
• The production rules are expressed in natural
language.
• The production rules are highly modular, so
we can easily remove, add or modify an
individual rule.
Disadvantages of Production Rules
• Production rule system does not exhibit any
learning capabilities, as it does not store the
result of the problem for the future uses.
• During the execution of the program, many
rules may be active hence rule-based
production systems are inefficient.
Scripts
• A script is a structured representation describing a
stereotyped sequence of events in a particular context.
• Scripts are used in natural language understanding
systems to organize a knowledge base in terms of the
situations that the system should understand. Scripts use a
frame-like structure to represent the commonly occurring
experience like going to the movies eating in a restaurant,
shopping in a supermarket, or visiting an ophthalmologist.
• Thus, a script is a structure that prescribes a set of
circumstances that could be expected to follow on from
one another.
Advantages of Scripts
• Events tend to occur in known runs or
patterns.
• A casual relationship between events exist.
• An entry condition exists which allows an
event to take place.
• Prerequisites exist upon events taking place.
Components of Scripts
• Entry condition: These are basic condition which must
be fulfilled before events in the script can occur.
• Results: Condition that will be true after events in script
occurred.
• Props: Slots representing objects involved in events
• Roles: These are the actions that the individual
participants perform.
• Track: Variations on the script. Different tracks may
share components of the same scripts.
• Scenes: The sequence of events that occur.
Symbols used in Script
Example of a script
Example:-Script for going to the bank to withdraw money.
SCRIPT : Withdraw money
TRACK : Bank
PROPS : Money
Counter
Form
Token
Roles : P= Customer
E= Employee
C= Cashier
Entry conditions: P has no or less money.
The bank is open.
Results : P has more money.
Scene 1 :: Entering
P PTRANS P into the Bank /// goes to bank
P ATTEND eyes to E /// looks for employee
P MOVE P to E /// goes to employee
Scene 2 :: Filling the form
P MTRANS signal to E /// P tells E
E ATRANS form to P /// E forms to P
P PROPEL form for writing ///P fills form
P ATRANS form to P /// P takes form
E ATRANS form to P ///E takes form from P
Scene 3 :: Withdraw of money
P ATTEND eyes to counter
// P looks for counter
P PTRANS P to queue at the counter
// P stands in the queue
P ATRANS token to C
// P gives token to cashier
C ATRANS money to P
// C gives money to customer
Scene 4 :: Exits Bank
P PTRANS go out of Bank
Advantages of Scripts
• Ability to predict events.
• A single coherent interpretation maybe builds
up from a collection of observations.
Disadvantages
• Less general than frames.
• May not be suitable to represent all kinds of
knowledge
Horn Clause
Horn clause is a disjunction with at most one
positive literal.

A V ~A

Disjunction Negative Sign


Positive
literal /
As there is no
sign infront
Examples to check
• A U B U ~C (NO  Because 2 positive literals)
• A ꓵ ~B ꓵ ~C (NO  Because it contains
Conjunction symbols)
• ~A U ~B U ~C U……………………………….U ~X U Y
(Yes)
• ~A U ~B (Yes )
• A
Conjunction ꓵ
A conjunction is true when all the values in a
formula are true

A B A ꓵ B
T F F
F T F
F F F
T T T
Disjunction
A disjunction is true when at-least one value in
the formula is true.

A B A ꓵ B
T F T
F T T
F F F
T T T
Resolution
• Clause :: {C}, {D}, {B,~D},{A,~B,~C}
• Prove :: {A}  True
• ~ ( ~A )
Clause :: {C}, {D}, {B,~D},{A,~B,~C}
~A
A,~B,~C

~B,~C
B,~D

~C,~D
C

~D
D

NULL

You might also like