Module-5
Knowledge Representation
By,
Mr. Manjunatha P B
Asst. Professor
Department of AI & ML, BIT
Introduction
2
▶ Discussed Problem solving techniques :Search graphs of Solution paths, Predicate logic for storing knowledge and inferenceing new knowledge while solving problems requiring concepts of AI.
▶ Knowledge Representation is important in cognitive science & AI.
system should possess properties such as learning, efficiency in acquisition,
representational adequacy, and inferential adequacy.
Introduction
3
▶ Learning: Refers to a capability that acquires new knowledge, behaviors, understanding etc.,
▶ It adds new classified information to avoid redundancy and replication in the existing knowledge prior to storage to enable easy retrieval.
▶ Efficiency in acquisition: Refers to ability to acquire new knowledge using automatic methods wherever possible rather than relying on human intervention.
▶ Representational adequacy: Refers to ability to represent the
required knowledge.
▶ Inferential adequacy: Refers to the ability of manipulating knowledge to produce new knowledge from existing one.
Introduction
4
▶ KR is the core component of a number of applications such as expert systems, Machine Translation Systems, Computer aided maintenance systems, information retrieval systems & DB front ends.
▶ In expert systems- Using predicate logic( in the from of rules & Facts), semantic networks, frames, conceptual dependency etc., Knowledge is represented.
▶ Knowledge representation Techniques:
Approaches to Knowledge representation
5
▶ AI programs use structures known as Knowledge structures to represent Objects,facts,relationshps & Procedures.
▶ The main objective is to provide information so that program
can operate in intelligent way.
▶ Knowledge structures composed of both traditional & complex structures such as semantic work, frames, scripts etc.,
▶ Knowledge base is a special type of data base that holds knowledge of that domain and share functions such as storing, updating and retrieving information.
▶ They are organized in hierarchical structures with in–built
inheritance & inferencing capabilities.
Approaches to Knowledge representation
6
objects consisting of attributes and associated values.
Name | Age(in years | Sex | Qualification | Salary(Rs) |
John | 38 | Male | Graduate | 20000 |
Mike | 25 | Male | Undergraduate | 15000 |
Mary | 30 | Female | Ph D | 25000 |
James | 29 | Male | Graduate | 18000 |
Approaches to Knowledge representation
7
Eg: knowledge regarding mortality such as All humans are mortal can not be represented using relational approach.
🡪The advantage of this approach are that we can represent a set of rules, derive more facts, truths and verify the correctness of new statements.
Eg: If we have fact John is human, then we can infer that John is mortal.
Approaches to Knowledge representation
8
Eg: An interpreter for a PL interprets a program on the basis of available knowledge (Syntax and semantic of the language).
knowledge can be easily represented.
Knowledge representation using Semantic Network
9
Eg: Every human, animal and bird are living things who can breath and eat.A cat has fur and is an animal. All animals have skin and can move. A giraffe is an animal and has long legs and is tall. A parrot is a bird and is green in color. John is a human.
Knowledge representation using Semantic Network
10
kind or subclass of the other concept.
Eg: Man is a human i.e Man is a sub class of the human class.
john is an instance of Man.
Knowledge representation using Semantic Network
11
Knowledge representation using Semantic Network
12
concept to its property.
Eg: Querry-Does a parrot breath? Can be easily answered as ‘Yes’ even though this property is not associated directly with parrot.
Knowledge representation using Semantic Network
13
Knowledge representation using Semantic Network
14
is the name of the relations.
Knowledge representation using Semantic Network
15
of knowledge representation allows
stored at the highest possible level of
abstraction which reduces the size of the knowledge base.
Property Inheritance algorithm
16
Input: Object and property to be found from semantic net:
Output: Returns yes, if the object has a desired property else returns false.
Procedure:
▶ Find an object in the semantic net:
▶ Found=false
▶ while [(object ≠ root)] DO
{
If there is an attribute attached with an Object then found=true:
else {object = isa(object,class) or object=inst(object,class)}
}:
▶ If found=true then report ‘Yes’ else report ‘No’;
Inheritance in Semantic Network-Prolog facts
17
the form of facts and inheritance rules.
isa facts | Instance facts | Property Facts |
isa(living_thing,nil) | Inst(john,mam) | Prop(breathe,living_things) |
isa(human,living_thing) | Inst(giraffe,animal) | prop(eat,living_thing) |
Isa(animals,living_thing) | inst(parrot,bird) | Prop(two_legs,human) |
Isa(birds,living_thing) | | Prop(skin,animal) |
Isa(man,human) | | Prop(move,animal) |
Isa(woman,human) | | Prop(fur,bird) |
Isa(cat,animal) | | Prop(tall,giraffe) |
| | Prop(long_legs,giraffe) |
| | Prop(tall,animal) |
| | Prop(green,parrot) |
Inheritance rules in Prolog
18
:- inst(X,Y)
:- inst(X,Z), subclass(Z,Y)
:- isa(X,Y)
:- isa(X,Z), subclass(Z,Y)
:- prop(X,Y)
:- instance(Y,Z),property(X,Z)
:- subclass(Y,Z), property(X,Z)
Various queries for Inheritance Program
19
English Query | Prolog Goal | Output |
Is John Human ? | ?-instance(john, humans) | Yes |
Is parrot a living being | ?- instance(parrot, living_thing) | Yes |
Is giraffe an animal | ?- instance( giraffe, animal) | Yes |
Is woman a subclass of living thing ? | ?- subclass(woman,living_thing) | Yes |
does parrot fly? | ?- property(fly, parrot) | Yes |
Does parrot have fur? | ?- Does parrot have fur? | Yes |
Does John breathe? | ?- property(john,breathe) | Yes |
Does cat fly | ?- property(fly,cat) | No |
Semantic Nets
20
▶ Consider the data
▶ Tom is a cat.
▶ Tom caught a bird.
▶ Tom is owned by John.
▶ Tom is ginger in colour.
▶ Cats like cream.
▶ The cat sat on the mat.
▶ A cat is a mammal.
▶ A bird is an animal.
▶ All mammals are animals.
▶ Mammals have fur
Semantic Nets
21
Extended Semantic Networks for KR
4/20/20219:21 AM
22
▶ Two formalism that can be used for Knowledge representation are
Logic, semantic networks.
▶ Semantic network is represented as a directed graph whose nodes represent concepts/objects and arcs represent relationships between concepts /objects.
▶ Eg: Represent in semantic network the English sentences John gives an apple to mike and John and mike are human .
Extended Semantic Networks for KR
23
▶ ‘E’ represents an event which is an act of giving, whose actor is ‘John’,
the object is an apple and recipient is mike.
▶ Semantic net can hold semantic information about situation such as actor of an event giving is john and object is apple, in the sentence John gives an apple to mike.
▶ The relationship in the network can be expressed in clasual form of logic as follows :
object(E,apple)
Action(E,give)
Actor(E,John) Recipient(E,mike) Isa(john,human) Isa(mike,human)
Extended Semantic Networks for KR
24
▶ Predicate relations corresponding to labels on the arcs of semantic
networks always have two arguments.
▶ The entire semantic net can be coded using binary representation (2 arguments representation) .
▶ In first order predicate logic, predicate relation can have n arguments ,
where n >=1
Eg: John gives an apple to mike is represented in predicate logic by give( john,mike,apple) which has 3 arguments and give is predicate relation.
▶ Predicate logic representation has greater advantages
Eg: John gives an apple to everyone he likes can be expressed as
give(john,X,apple)🡨(john,X)
where X is a variable representing any
individual. 🡨 implied by, LHS=conclusion and RHS contains conditions.
Extended Semantic Networks for KR
25
▶ It is not convenient to add an n-array representation of predicate
logic.
▶ Eg: if we have 3-array relationship give(John,mike,apple) representing John gives an apple to mike and suppose additional information kitchen is added in the sentence John gives an apple to mike in the kitchen, then replace the 3-ary representation.
give(john,mike,apple) by 4-ary representation
give(john,mike,apple,kitchen)
Eg: If john gives something he likes to a person, then he also likes that
person can be expressed in clasual representation as
Likes(John,X)🡨give(john,X,Y),likes(john,Y)
▶ The sentence every human is either male or female can be expressed as
Male(X),female(X)🡨human(X)
Extended Semantic Networks for KR
26
▶ In conventional semantic network, we cannot express clausal
form of logic.
▶ To overcome this short coming, R.Kowalski and his colleagues(1979) proposed an extended semantic network(ESNet) that combines the advantages of both logic & semantic networks.
▶ ESNet has same expressive power as that of predicate logic with well defined semantics, inference rules, and a procedural interpretations.
▶ It incorporates the advantages of using binary relation as in semantic network than n-ary relations of logic.
▶ ESNet is a much powerful representation as compared to logic & Semantic network.
Extended Semantic Networks for KR
27
▶ Binary predicate symbols in clausal logic are represented by
labels on arcs of ESNet.
▶ An atom of the form love(john,mary) is an arc labelled as love
with its two end nodes representing john and mary.
▶ The direction of the arc(link) indicates the order of the
arguments of the predicate symbol.
love
john mary
▶ Conclusions(Positive atoms) are represented with continuous arrow lines called Assertion links(🡪).
▶ Conditions(Negative atoms) are represented with dotted arrow lines called denial link(------->)
Extended Semantic Networks for KR
28
Eg: Clausal representation
grandfather(X,Y)🡨father(X,Z),parent(Z,Y) for grandfather in logic can be represented in ESNet. X& Y are variables,
grandfather(X,Y) is the consequent(conclusion), father(X,Z) and parent(Z,Y) are antecedents(Conditions)
Extended Semantic Networks for KR
29
Eg: Clausal rule male(X),female(X)🡨 human(X) can be
represented using binary representation as
isa(X,male),isa(X,female)🡨isa(X,human)
▶ ESNet representation is shown below
Inference Rules
30
▶ Inference rules are embedded in the representation itself.
▶ The representation of the inference for every action of giving, there is an action of taking in clausal logic is
action(f(X),take)🡨action(X,give)
▶ The interpretation of this rule is that event of taking action is a function of the event of giving action.
▶ In ESNet representation ,functional terms, such as f(X), are represented by a single node.
▶ The representation of the statement in ESNet
action(f(X),take)🡨action(X,give)
Inference Rules
31
▶ The inference rule that an actor who perform taking action is also the recipient of this action & can be represented in clausal logic. E is the variable representing an event of an action of taking.
recipient(E,X)🡨action(E,take),actor(E,X)
Inference Rules
32
▶ Represent the following clause in ESNet recipient(E,X) 🡨 action(E,take),actor(E,X) Object(e,apple), action(e,take), actor(e,John)
Solution: ‘E’ is a variable of some event and ‘e’ is an actual event.
Inference Rules
33
▶ Partition is shown in the figure to delimit the clause pictorially
by enclosing the clausal rule in an ellipse.
▶ The hierarchy links isa, inst and part_of are shown as special case in ESNet.
▶ Part-of link has a hidden existential quantifier.
Eg: Assertion every human has two legs could be represented using part_of link.
part_of
two_legs human
Interpretation is that for every human, there exist two legs which are part of that human.
Inference Rules
34
▶ In the figure, P part_of X is conclusion and P part_of Y is
condition, where Y is linked with X via isa link.
▶ Such kind of representation is contradictory and hence is a contradiction in ESNet.
Deduction in Extended Semantic Networks
35
Forward Reasoning Inference:
▶ FRI in clausal logic derives new assertion from old ones, start with given assertions and derive new assertions using clausal rule.
Eg: Consider set of clauses: isa(X,human) 🡨isa(X,man)
isa(john,man)
Forward Reasoning Inference
36
isa(john,human) holds true.
Forward Reasoning Inference
37
Backward Reasoning Inference
38
method in clausal logic.
Eg: Prove isa(john,human) using ESNet given the set of clauses
represented in clausal form.
Backward Reasoning Inference
39
Backward Reasoning Inference
40
Examples illustrating Inference Methods
41
🡨 isa(x,animate)
🡨 isa(X,human)
🡨isa(X,man)
isa(X,living_thing) isa(X,animate) isa(X,human) isa(john,man)
▶ Illustrate both inferencing methods for the ESNet representation
▶ John is a living_thing can be derived by binding X with John.
Examples illustrating Inference Methods
42
Forward Reasoning Inference Method
43
▶ Infer john is animate. The assertion john is a living_thing can
be inferred as follows.
Forward Reasoning Inference Method
44
Forward Reasoning Inference Method
45
Backward Reasoning Inference Method
46
▶ Prove a query isa(john,living_thing).
▶ Add a denial of the fact that John is not a living_thing in ESNet .
▶ Check whether inconsistency or an empty network can be
derived.
▶ Each part shows the reduction in the network by the elimination of assertions and their denial links with the help of appropriate substitutions.
▶ Denial links are enclosed in rectangular box to distinguish it
from rest network.
▶ Dotted lines are denial links, continuous lines are assertion links.
▶ These are removed after substitution of actual value of a variable.
Backward Reasoning Inference Method
47
Backward Reasoning Inference Method
48
Solving query isa(john,living_thing)
49
Example
50
▶ The sentences ‘Anyone who gives something he likes to a person likes that person also, John gives an apple to Mike, John likes an apple’ can be expressed in both binary clausal form and ESNet representation.
▶ Clausal Representation of the sentence can be written as
likes(X,Z)🡨action(E,give),object(E,Y),actor(E,X),recipient(E,Z),likes(X,Y) action(e,give)
object(e,apple)
actor(e,john) recipient(e,mike) likes(john,apple)
51
ESNet representation
▶ Prove likes(john,mike) using both Forward & Backward reasoning inference
Forward Reasoning Inference
52
▶ To get the desired assertions, reduce the network by resolving clauses. Eliminate assertion and its corresponding denial with likes links by unifying Y=apple & X=John
▶
Forward Reasoning Inference
53
▶ The reduced network can be further reduced to the following conclusion by unifying E=e and Z=mike.
E=e , Z=mike
likes
john --------------------------🡪mike
▶ Link likes between john and mike is deduced after eliminating all links which are assertions and denials.
Eg: action(e,give) is an assertion and action(E,give) is a denial, which is a contradiction and is hence eliminated.
Backward Reasoning Inference
54
▶ To prove likes(john,mike), add the denial link to the network and try to reduce the network to empty.
▶ The denial link is
▶ The reduction of the network is shown step by step.
▶ Denial link is enclosed in rectangular box.
Backward Reasoning Inference
55
Backward Reasoning Inference
56
Backward Reasoning Inference
57
Inheritance
58
▶ In a conventional Semantic network, lower level nodes in isa hierarchy inherit properties from higher level nodes unless the properties are redefined in the node itself.
🡨 isa(x,animate)
🡨 isa(X,human)
🡨isa(X,man)
isa(X,living_thing) isa(X,animate) isa(X,human) isa(john,man)
▶ Show that John inherits the property of having two_legs from human.
ESNet for Inheritance
59
Addition of denial link to the network
60
Obtaining a Contradiction
61
Knowledge representation using Frames
62
▶ The knowledge representation using frames was introduced by Marvin Minsky(1975).
▶ Frames are extension to semantic nets.
▶ Each node of a semantic net is represented by a frame.
▶ A frame is a data structure consists of a collection of attributes or slots and associated values that describe an entity.
▶ There are several types of information attached to each frame.
▶ Frames are similar to concept of class in object oriented paradigm.
▶ Frames consists of attributes or slots.
Knowledge representation using Frames
63
▶ Slots are described with attribute value
pairs<slot_name,value> .
▶ Slots are complex structures that have filters describing their properties.
▶ The value of the slot can be a text string, constant or an integer or it may be another frame or contain methods.
Knowledge representation using Frames
64
Knowledge representation using Frames
65
▶ Frame may contain as many <slots-filter> pairs as required to describe
an object. Each slot may contain one or more facets given below
Facet Name | Description |
Value | Value of the slot |
Default | Default value of the slot and it may be redefined by the lower classes |
Range | The range of integer or enumerated values that a slot can have |
Demons | Procedural attachments such as if_needed, if_deleted, if_added ,etc. |
Other | May contain rules, other frames, semantic net, or any type of information |
Knowledge representation using Frames
66
▶ Frame may contain as many <slots-filter> pairs as required to describe
an object. Each slot may contain one or more facets given below
Facet Name | Description |
Value | Value of the slot |
Default | Default value of the slot and it may be redefined by the lower classes |
Range | The range of integer or enumerated values that a slot can have |
Demons | Procedural attachments such as if_needed, if_deleted, if_added ,etc. |
Other | May contain rules, other frames, semantic net, or any type of information |
Knowledge representation using Frames
Example: Hospital Frame
67
Slot Name | Facet Name | Facet Value |
F_name | Value | Metro Hospital |
Country | default | India |
Phone_No | default | 123245678 |
Address | default | abc |
Knowledge representation using Frames
68
Eg: The class child hospital is a kind of class hospital.
Eg: AIIMS is an instance of the class frame hospital. An
instance class possesses the same structure as its class frame.
Eg: ward is part_of class hospital.
Frame Description
69
F_name: | Hospital |
Country: | (Value-India) |
Phone_No: | ( default-2345612) |
Address: | (default-NewDelhi) |
Director | (default_xyz) |
Labs: | Lab(Lab Frame) |
Wards: | Ward(Ward Frame) |
Doctors: | Doctor(Doctor Frame) |
Frame Description-Continued..
70
F_name: | Child Hospital |
Ako: | Hospital( Hospital Frame) |
Age: | (range-[0-12]),(rule-if added) |
F_name: | Heart_hospital |
Ako: | Hospital( Hospital Frame) |
F_name | lab |
Part_of | hospital(Hospital Frame) |
Pathology | Pathology(Pathology Frame) |
X_Ray | X_ray ( X-Ray Frame) |
Frame Description-Continued..
71
F_name: | ward |
Part_of: | Hospital( Hospital Frame) |
Ortho: | Orthopaedic(Orthopaedic ward frame) |
F_name: | Doctor |
Part_of | Hospital |
Qualification | (default-MBBS) |
F_name | Pathology |
Part_of | Lab(Lab Frame) |
Incharge | (Default-XYZ) |
Type of tests: | … |
Frame Description-Continued..
72
F_name: | X_ray |
Part_of: | Lab(Lab Frame) |
Incharge | (Default-PQR) |
F_name: | Orthopaedic |
ako | Ward(Ward Frame) |
Frame Instance Description
73
F_name: | AIIMS |
Inst: | Hospital Frame |
Phone_No: | (Value-91996591425) |
Address: | (value-Central-Delhi) |
City: | (value-New Delhi) |
Director: | (Value-Dr.Smith) |
Labs: | (Lab-name) |
Wards: | Wards Frame Instance |
Doctors: | Doctors Frame Inst |
Frame Instance Description
74
F_name: | Lab-name |
Inst: | Lab(Lab Name) |
Part_of: | AIIMS(Hospital Frame Instance) |
Pathology: | Pathology Frame Instance |
X_Ray: | X_ray Frame Instance |
F_name: | Pathology-lab-name |
Inst: | Pathology(Pathology Frame) |
Part_of: | Lab-names(Labs Frame Inst) |
Incharge: | (value-Mr.John) |
Types of tests: | (Value-[ECG,Blood Test,Urine]) |
Frame Instance Description
75
F_name: | kalawati |
Inst: | Child_Hospital(Child Hospital Frame) |
Address: | (Value-1234 New Delhi) |
Phone: | (value-0116573891 |
Direction: | Dr.Mike |
F_name: | escorts |
Inst: | Heart_hospital( Heart Hospital Frame) |
Phone_No: | (value-0114563732) |
Address: | (value-Faridabad) |
76
A simple frame System for the class ‘hospital’
⮚