You are on page 1of 72

Topic Two

KNOWLEDGE REPRESENTATION, REASONING


AND INFERENCE
KR concepts KRI Concepts
• Parent/child objects • Pattern matching/
• Inheritance instantiation/
• Elementary/compound unification
proposition • Goal/sub-goal rules
Representation

Reasoning & Inference


• Tautology/inconsistent/ • Primitive/non-primitive
contingent formula premises
• Rule fire/not fire
KR Techniques
• Semantic network
KRI Techniques
• Propositional logic • Modus Ponens
• Predicate calculus • Forward chaining
• Rules • Backward chaining
Operators
• , , , , 
Knowledge

Meta-knowledge

Knowledge

Information

Data

Noise
Knowledge
State of
knowing

Familiarity Understanding

Body of
facts
• Undeniable • Deniable
• Universally true • Derived
from senses
CHARACTERISTICS

Priori Posteriori

Explicit Tacit

• Conscious • Unconsciou
• Documented s
• Undocumen
ted
• Ice is cold • Beggars are
EXAMPLES • Cloud has no pillar poor

Priori Posteriori

Explicit Tacit

• Books, reports, • Resides in


CDs, videos etc someone’s
mind
Types of Knowledge
Knowledge about Facts/statements describing
knowledge object, people, place,
event etc. Describes
‘knowing that’

Declarative
Experience-based, Meta-knowledge
Structural
Heuristic
Procedural
mental short cut Describes how
to ease cognitive learners use/apply their
load declarative knowledge.
Describes
‘knowing how’

Understanding of domain /
discipline. Describes ‘knowing why’
Declarative

She is beautiful.

The sun rises in the East.

My room number is 2013.

UUM is located in Sintok.


Procedural

E.g. “to make half-cooked egg, first boil some


water ….”

E.g. solving problems, forming plans, making


arguments

IF .. THEN rule format:


rains  bring umbrella ; hungry  get food
Structural

Mediates transition of declarative knowledge into


procedural knowledge

Describes how concepts within a domain are


interrelated

E.g. relationship between ‘instruction’ and ‘learning’


Heuristic …
Rule of thumb
Speed up process
of finding
solutions – in
complex
problem / Guided instinct
incomplete / educated
information guess

Display
individual Intuitive
expertise judgment
Meta-Knowledge

Knowledge
about
knowledge. Know which is
which.
Source of Knowledge
Non-
Documented
documented

Tacit Explicit

Experience Printed Digital


/ heuristic documents media
Knowledge Representation
A science of
translating actual
knowledge into a
format that can
be used by the
computer
Knowledge Representation
REAL
WORLD

Translate into internal representation


Inference: deduction,
search, planning, INTERNAL REPRESENTATION
learning, explanation
Translate back into terms
Understandable by humans
REAL
WORLD
Knowledge Representation Process

Extract

Use Represent
KR method/technique
• Associative network:
Object- semantic network, frames;
based decision table, decision tree

Logic- • Propositional logic


based / • Predicate calculus (FOPL)
Formal logic

Rule-based • IF <condition> THEN


<action>
• Physical,
Object
abstract

OAV
• Numerical,
Property string, boolean
values • Single, multi-
value
OAV

“The chair’s color is red and priced at


RM 35.00 ”

“I have a brother named Johnny. The


8 years-old brother likes to play
tennis and football.”
OAV

Describe Doraemon in
OAV form
OAV
color
shape

appearance
Doraemon appearance

hobby

no. of legs
Associative/Semantic Network
Not
Not
real
real exis
te nce
Cartoon
Cartoon
isa
Kids ves-by Doraemon
Kids lo isa

… … …
… … …
Semantic Network

Method of knowledge representation that


uses graph made up of nodes and arcs
• Nodes - objects / properties
• Arcs – relationship between objects
Flamingo is a bird. Typically bird has wings and
travel by flying. Bird category falls under
animal kingdom. All animal requires air to
breathe. Ostrich is a bird but travels by
walking.

Wings
s
ha
is-a is-a
Flamingo Bird Animalbreathe Air
a ttrraa
is- vvee
ll
Fly
Ostrich trave
l

Walk
NOTE: This is an exceptional handling
value. It overwrites the property ‘flying’ of birds (as ostrich doesn’t fly).

… …

fly
fly
can …
… Clow
Clow

… nn

in

sta
Plants

cen
-o
Birds

f
Fish …
multi
motile
motile …
multi
cellula
cellula
rr
Living breathe
breathe
Animal

… things
Repti
… Amphi les

bians
Mam

… Bacteri
mals
a



… …



Exercise
Albatross and Kiwi are two types of bird. Albatross has
black and white color while Kiwi is brown. Albert and
Ross are two albatross. Generally, all birds travel by
flying and active during the daytime. Kiwi, however,
travel by walking and active during the night time. Kim
is a kiwi.
Exercise
Flashdance is a male horse owned by Morrison Harris.
Either its owner or anyone who lives in the city of
Florence loves Flashdance. Flashdance died on
Christmas Eve.
Florence horse
residence isa
love
s_by
Flash isa male
dance

b y died_on
es _ s
lov n Christmas
ow
eve
Morrison
Harris
Exercise
There are three types of computer, i.e. mainframe,
mini computer and personal computer (PC). All
computers use Unix operating system. Win95
operating system only operates on PC. Mainframe
computer is expensive, mini computer is moderately
expensive while PC is cheap. Nano is a brand of PC
which is so cheap and using Unix operating system.
Nano is owned by Sam.
moderately
expensive
expensive

price price

mini-
mainframe computer

type type

computer

OS
type UNIX

PC

OS
price OS
an-instance-of

Win95
cheap Nano
Exercise
Company ABC is a software development company.
Three departments within the company are Sales,
Administration and Programming. Joe is the manager
of Programming. Bill and Sue are programmers. Sue is
married to Sam, who is an editor for Prentice Hall.
They have three children, and they live on Elm Street.
Sue wears glasses and is 1.65m tall.
Exercise
Slither and Sidney are two grass snakes. They are in
small size and green color. Sidney, like the other grass
snakes, eats meat. Slither, however, is a vegetarian
and therefore, does not eat meat. Grass snake is a
type of snake, which is a reptile with no legs.
Crocodile is also a reptile.
Exercise
James is a seagull. Like all birds, seagulls have two
wings and can fly. They love to eat fish. James has a
friend named Sean, a penguin. Even though penguins
are also birds, they cannot fly. Instead, they walk.
Penguins can only survive at places with cold
temperature. Just like seagulls, their major source of
food is fish which they caught in the icy cold water
where they live.
Exercise
Paddy is a giant panda who lives in a zoo in central
China. Panda is easily recognized by large and
distinctive black patches around the eyes, over the
ears and around its body. Panda’s main diet is
bamboo; however, wild pandas also eat other grasses
or even meats. Pandas in captivity, like Paddy, also eat
honey, eggs, fish and bananas. Paddy the giant panda
is an endangered species similar to Willie the blue
whale, Tuti the green sea turtle, Mat the Malayan tapir
and Tassy the Tasmanian devil. They are all facing a
very high risk of extinction.
Exercise
Eagles are big, powerful birds with wingspread about 2 metres,
weighs between 3.5 to 5.5 kgs and length about 1 meter.
Eagle’s beak is large and hooked and its toes has strong claws
on its end. Also known as hunter, eagle catch and eat small
animals and fish, but only hunt in the daytime. Three types of
eagles are bald, sea and golden eagle. The bald eagle has white
feathers covering its head while its body and wings are dark
brown. Its eyes, beak and feet are yellow. It fonds of fish and
likes to live near water, mostly in Alaska. Sea eagles live in
Greenland, Europe, Asia and Africa. The golden eagle breeds in
the mountains of North America and other parts of the world.
It is somewhat golden on the back of its neck, the rest of its
body is brown. Its legs are covered with feathers all the way to
its feet.
Inheritance !!
Important concept in object-based
representation
Formal Logic Oldest form of KR in computer

Concerned with truthfulness

2 kinds of logic: Propositional Logic Predicate Calculus / FOPL

Implemented in PROLOG

Manipulate BICONDITI
Boolean operators AND OR NOT IMPLIES ONAL
Propositional Logic
Boolean
logical
operators


(BICONDITIO
NAL)

 
(IMPLIES) (NOT)

 
(AND) (OR)
Propositional Logic
E.g.

elementary/single
proposition
kitty_gets_w
et
(Q)

kitty_is_outsi
it_is_raining
de
(R)
(P)
Propositional Logic
E.g.
PQ
PRQ

kitty_gets_wet
(Q) Compound
Compound proposition
proposition
is
is made
made up
up of
of
operator
operator and
and >1
>1
elementary
elementary propositions
propositions

kitty_is_outside it_is_raining
(R) (P)
Example 1:


Normal: The sky is blue and windy. It is really great for picnic

Logic: P  Q  R

Example 2:


Normal: If the weather is cloudy, then it will be raining. If it is raining, people will stay at
home.

Logic: (A  B)  (B  C).

Example 3:


Normal: I will rather stay if and only if it is raining.

Logic: X  B
it_is_raining  kitty_is_outside 
kitty_gets_wet
Nested formulae (it_is_raining  kitty_is_outside)
express the actual meaning  kitty_gets_wet
of a formula. it_is_raining  (kitty_is_outside
 kitty_gets_wet)
highest 

 Higher precedence operator


Higher precedence operator
becomes principle operator.
becomes principle operator.

Principle operator
Principle operator
breaks formula
breaks formula
 into 2.
into 2.

lowest  Order of precedence


Truth table
• Method to prove the truth value of any statement
written in PL.

P Q P PQ PQ PQ PQ


T T F T T T T
T F F F T F F
F T T F T T F
F F T F F T T
Types of Formula



Formula is always T


E.g. (P(PQ))Q
Tautology



Formula is sometimes T
sometimes F


E.g. (AB)C
Contingent
Propositional Logic Limitation
1. Cannot express universality of objects


E.g.

“all computers have processor”

“all birds flly”

E.g. “all birds fly”


parrot_flies  canary_flies  backyard_bird_flies  ………..
Propositional Logic Limitation
2. Cannot express existence / inexistence /
partial quantity of objects


E.g.

“some UUM students are international students”

“none of us is immortal”

E.g. “some UUM students are international


students”


jason_international_student  fifi_international student  ……
Propositional Logic Limitation

E.g. “none of us is immortal”


ali_mortal  raju_mortal  siti_mortal  soolim_mortal
 …..
Propositional Logic Limitation
Solution

Use predicate calculus / First –


Order Predicate Logic (FOPL)
Predicate Calculus
Predicate
Notation / logic statement that consists of:



predicate name


describe / relates the arguments

Functor
Structure of Predicate


functor(argument1, argument2, …,
argumentN)

Structure

Describing:
name of relation / adjective / verb / possession
Relationship becomes functor

“she likes chocolate”

Objects becomes arguments

likes(she,chocolate)
teaches(X,Y)
s Y
a c he
X te
Variables – can be
instantiated with
any values
likes(she, chocolate)

teaches(X, Y)

likes(X, chocolate)

likes(she, What)

teaches(sue, Course)

teaches(Who, stin1013)

teaches(sue, _)
likes(she, chocolate)

tEACHES(X, Y)

liKeS(X, chocolate)

Note: Functor MUST always start with a


lowercase letter
likes(she, chocolate)

tEACHES(X, Y)

liKeS(X, chocolate)

Note: Arguments can be all constant / all


variables / combination of both
teaches(X, Y)

likes(she, What)

teaches(sue, _)

Note: Variables can be written using a single uppercase letter / a


meaningful word that starts with an uppercase letter /
underscore symbol
Quantifier (universal) 

Expression true for e.g.


e.g.
ALL values of
‘for all’ designated
X X (bird(X) 
variables likes(X,icecream) flies(X))

“everybody likes icecream” “all birds fly”


Quantifier (existential)

Expression true for e.g. e.g.


SOME values of
‘there exist’. designated
X X (bird(X) 
variables likes(X,icecream) flies(X))

“some people like icecream” “some birds do not fly”


Some examples
• E.g. 1:
• Normal: If it doesn’t rain today, Ahmad will go
to the beach
• PL: A  B
• FOPL: “rain(today) goto(ahmad, beach)”

• E.g. 2:
• Normal: All volleyball players are tall
• FOPL: “X (volleyball_player (X)  tall (X))”
Some examples
• E.g. 3:
• Normal: Some people like durian.
• FOPL: “X (person(X)  likes(X, durian))”
‘there exist X such that X is a
person and X likes durian’

 E.g. 4:
◦ Normal: Nobody likes war
◦ FOPL: “ X likes (X, war)” OR
◦ “X likes(X,war)”
‘there does not exist X such
that X likes war’
Rules
A knowledge structure that relates some known
information to other information and that can be
concluded or inferred to be known.

Procedural knowledge

Structure: IF <antecedent> THEN <consequent>

PL or FOPL notations
Rules - Structure

Antecedents


located before THEN

also called Premise or Condition

Consequence


located after THEN

also called Conclusion or Action
Rules - Examples
IF CGPA is high THEN approve admission

IF engine sounds strange THEN check the engine parts

IF hungry THEN get some food

IF siren rings THEN run out immediately

IF cough continuously THEN see a doctor


Rules - Examples
IF CGPA is high THEN approve admission

antecedent consequent
premise conclusion
condition action

A  B

high(cgpa)  approve(admission)
Diagnosing strep throat

Rule 1:
IF patient has a sore throat (P1)
AND suspect bacterial infection (SG2)
THEN patient has strep throat (G1)

Rule 2:
IF patient temperature is > 37°C (P2)
THEN patient has a fever (SG1)

Rule 3:
IF patient has been sick > a month (P3)
AND patient has a fever (SG1)
THEN suspect bacterial infection (SG2)
Diagnosing strep throat

Rule 1: P1  SG2  G1

Rule 2: P2  SG1

Rule 3: P3  SG1  SG2

You might also like