Sunteți pe pagina 1din 36

Knowledge Representation

•Propositional Logic
• Predicate Logic
• Semantic Networks
• Frames
• Fuzzy Logic

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 1


Propositional Logic
 A formal method of reasoning, which represents knowledge,
allowing automated inference and problem solving.
 Concepts are translated into symbolic representations which
closely approximate the meaning. These symbolic structures
can then be manipulated in programs to deduce various
facts, to carry out a form of automated reasoning.
 Propositional logic is the simplest.
– Symbols represent whole propositions (facts): P, Q, R, S,
etc..
– These are joined by logical connectives (and, or,
implication) e.g., P  Q; Q  R
– Given some statements in the logic we can deduce new
facts (e.g., from above deduce R)

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 2


Propositional Logic: Semantics
• Propositions
– Sentences and truth values
– Propositional connectives and their truth tables
• Negation: ~P
• Conjunction: P ۸ Q
• Disjunction: P ۷ Q (inclusive or)
• Implication: P  Q
• Equivalence: P  Q
– Other propositional connectives
• PQ (exclusive or), PQ (nor), PQ (nand),..
February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 3
Propositional Logic
 Propositions are some elementary atomic sentences.
Propositions may be either true or false. In propositional
logic, a world is represented as knowledge using a list of
facts.
 Syntax of PL :
 symbol -> P | Q | R | S | ...
 atomic sentence -> TRUE | FALSE
 sentence -> atomic sentence | complex sentence
 complex sentences -> ~ sentence | (sentence ^ sentence) |
(sentence v sentence) | (sentence  sentence) |
 (sentence  sentence)

 Precedence relation operators: ~,^,v,, .


February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 4
Propositional Logic: Examples
 My car is painted red.
 Snow is white.
 People live on the moon.
 Logical connectives:
 It is raining and the wind is blowing.
 I shall go there or ask kamal to visit him.
 If you study heard you will be successful.
 The sum of 20 and 30 is not 100.
 The car belongs to the VC is painted silver.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 5


Semantic Rules for Statements
Rule No. True Statements False Statements
1 T F
2 ~f ~t
3 t & t’ f&a
4 t or a a&f
5 a or t F or f’
6 at tf
7 fa t  f
8 t  t’ f  t
9 f  f ’
February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 6
Properties of Statements
Satisfiable: A statement is satisfiable if there
is some interpretation for which it is true.
Contradiction: A statement is said to be
contradictory (unsatisfiable) if there is no
interpretation for which it is true.
Valid: A statement is valid if it is true for every
interpretations. Valid statements are also called
tautologies.
Equivalence: Two sentences are equivalent if
they have the same truth value under every
interpretation.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 7


Semantics & Interpretations
P Q PQ PQ ~P PQ PQ

f f f f t t t

f t f t t t f

t f f t f f f

t t t t f t t

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 8


Meaning of Statements
What would be the meaning of the following statement, if
some interpretation imply true to P, false to Q and false to R ?:
((P & ~ Q)  R)  Q
Assignments:
1. Find the meaning of the statement:
(~ P V Q) & R  S V (~ R & Q)
for each of the interpretations given below:
I1: P is true, Q is true, R is false, S is true.
I2: P is true, Q is false, R is true, S is true.
2. Determine whether each of the following sentence is
(a) satisfiable (b) contradictory, or (c) valid
S1: (P & Q) V ~ (P & Q) S2: (P V Q)  (P & Q)
S3: (P & Q) R V~Q S4: (P V Q) & (P V ~Q) V P
S5: P Q ~P S6: P V Q & ~P V ~Q & P
February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 9
Meaning of Statements … ...
If the earth moves round the sun or the sun
moves round the earth, then Copernicus might
be a mathematician but wasn’t an astronomer.

Inspite of having French nationality, B. Russel


was a critic of imperilism, then either he was
not a bachelor or he was a universal lover.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 10


Rules of Inference
 Modus Ponens
 P  Q, P {((P  Q)  P)  Q}
∴Q
 Modus Tollens
 P  Q, ~ Q {((P  Q)  ~ Q)  ~ P}
∴~ P
 Hypothetical Syllogism (H. S.)
 (P  Q) & (Q  R)
∴P  R
 Disjunctive Syllogism (D. S.)
 (P V Q) ~ P
∴Q
 February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 11
Drawbacks of PL
 Propositional logic isn’t powerful enough
as a general knowledge representation
language.
 Impossible to make general statements.
E.g., “all students sit exams” or “if any
student sits an exam they either pass or
fail”.
 So we need predicate logic..

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 12


Predicate Logic
 In predicate logic the basic unit is a predicate/ argument
structure called an atomic sentence:
– LIKES (azad, chocolate)
– TALL (habib)
 Arguments can be any of:
– constant symbol, such as ‘azad’
– variable symbol, such as x
– function expression, e.g., FATHER_OF (hasan)
 So we can have:
– LIKES (X, chocolate)
– FRIENDS (FATHER_OF (rita), FATHER_OF (choiti))

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 13


Syntax of Predicate Logic
 These atomic sentences can be combined using
logic connectives
– LIKES (rita, hasan)  TALL (hasan)
– BASKET_BALL_PLAYER (hasan) 
– TALL (hasan)
 Sentences can also be formed using quantifiers
– x LOVELY (x) Everything is lovely.
– x LOVELY (x) Something is lovely.
– x IN (x, garden)  LOVELY (x) Everything in the
garden is lovely.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 14


Predicate Logic: Examples ...
 All employees earning TK. 30,000 or more per
year pay taxes.
 x ((E(x) & GE (i (x), 30000))  T(x)
 Some employees are sick today
 y ((E(y)  S(y))
 No employee earns more than the president
 x y ((E(x) & P(y))  ~GE((i (x), i (y)))

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 15


Examples of Predicate Logic
 Can have several quantifiers, e.g.,
– x y LOVES (x, y)
– x HANDSOME (x)  y LOVES (y, x)
 So we can represent things like:
– All men are mortal.
– No one likes hartal.
– Everyone taking AI will pass their exams.
– Every race has a winner.
– Sajjad likes everyone who is tall.
– Rita doesn’t like anyone who prefers arguments.
– There is something small and slimy on the table.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 16


Semantics of Predicate Logic
 There is a precise meaning to expressions in predicate
logic.
 Like in propositional logic, it is all about determining
whether something is true or false.
 x P(x) means that P(x) must be true for every object x
in the domain of interest.
 x P(x) means that P(x) must be true for at least one
object x in the domain of interest.
 So if we have a domain of interest consisting of just two
people, Hasan and Belal, and we know that TALL(hasan)
and TALL(belal) are true, we can say that x TALL(x) is
true.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 17


Semantic Net
 An long existing notion: there are different pieces of knowledge
of world, and they are all linked together through certain
semantics.
 knowledge is expressed as a collection of concepts, represented
by nodes (shown as boxes in the diagram), connected together
by relationships, represented by arcs (shown as arrows in the
diagram).
 certain arcs - particularly isa arcs - allow inheritance of properties.

Basic Components student


 Nodes
IS-A
– Represent concepts
 Arcs hasan FRIEND-OF
– Represent relations AGE

 Labels for nodes and arcs 21 rita


February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 18
Semantic Net
 Common arcs used for representing hierarchies include isa and has-part.
Example:
The Queen Mary is an ocean liner.
Every ocean liner is a ship

ship

IS-A

Ocean_liner

IS-A

Queen_mary

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 19


Semantic Net …..
 Common arcs used for representing hierarchies include isa and has-part.
HAS-PART
IS-A SHIP

Ocean Liner Oil Tanker Engine Hull

IS-A

Swimming Queen Mary Liver Pool Boiler


Pool
February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 20
Semantic Networks
 Knowledge is represented as a network or graph

animal HAS_PART

subclass subclass head

mammal
reptile
subclass

LIVES_IN
africa elephant large
SIZE
instance
Nellie apples
LIKES
February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 21
Knowledge Representation: Semantic Net
An long a n im a l
c o v e re d _ b y

existing
tr a v e ls _ b y s k in
fly in g
is a is a

notion: b ir d fis h
tr a v e ls _ b y

there are fe a th e rs
c o v e re d _ b y s w im m in g

different is a is a is a is a

pieces of o s tr ic h p e n g u in c a n a ry r o b in

knowledge tr a v e ls _ b y c o lo u r

of world, and
c o lo u r

they are all


w a lk in g y e llo w
tr a v e ls _ b y

linked re d

together in s ta n c e _ o f

through O pus in s ta n c e _ o f

certain T w e e ty

semantics.
c o lo u r
w h ite

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 22


Knowledge Representation: Semantic Net

 Developments of the semantic nets idea:


– psychological research into whether human
memory really was organised in this way.
– used in the knowledge bases in certain expert
systems: e.g. PROSPECTOR.
– special-purpose languages have been written
to express knowledge in semantic nets.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 23


Organization of Knowledge
 By traversing network we can find:
– That Nellie has a head (by inheritance)
– That certain concepts related in certain ways (e.g.,
apples and elephants).
 BUT: Meaning of semantic networks was not always well
defined.
– Are all Elephants big, or just typical elephants?
– Do all Elephants live in the “same” Africa?
– Do all animals have the same head?
 For machine processing these things must be defined.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 24


Major Limitations
 Lack of Semantics
– No formal semantic of the relations
 E.g. Does “ISA” mean subclass, member, etc?

– Possible multiple interpretations


– Restricted expressiveness
 E.g. can not distinguish between instance and class

Advantages:
 Easy to follow hierarchy, easy to trace association, flexible

Disadvantages:
 Meaning attached to nodes might be ambiguous
 exception handling is difficult
 difficult to program

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 25


Semantic Nets …
 Problems with semantic nets
– logical inadequacy - vagueness about what
types and tokens really mean.
– heuristic inadequacy – finding a specific piece of
information could be chronically inefficient.
– trying to establish negation is likely to lead to a
combinatorial explosion.
– "spreading activation" search is very inefficient,
because it is not knowledge-guided.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 26


Frames
 Devised by Marvin Minsky, 1975.
 Incorporates certain valuable human thinking
characteristics:
– Expectations, assumptions, stereotypes.
Exceptions. Fuzzy boundaries between classes.
 The essence of this form of knowledge representation
is typicality, with exceptions, rather than definition.
 a data structure for representing a stereotyped situation
 a network of nodes and relations organized in a hierarchy
 the topmost nodes - general concepts
 the lower nodes - more specific instances
 The idea of frame hierarchies is very similar to the idea of class
hierarchies found in object-orientated programming.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 27


How Frames are Organized
 A frame system is a hierarchy of frames
 Each frame has:
– a name.
– slots: these are the properties of the entity that has
the name, and they have values. A particular value
may be:
 a default value
 an inherited value from a higher frame
 a procedure, called a demon, to find a value
 In the higher levels of the frame hierarchy, typical knowledge about the
class is stored.
– The value in a slot may be a range or a condition.
 In the lower levels, the value in a slot may be a specific value, to
overwrite the value which would otherwise be inherited from a higher
frame.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 28


Frames … …
 An instance of an object is joined to its class by an
'instance_of' relationship.
 A class is joined to its superclass by a 'subclass_of'
relationship.
 Frames may contain both procedural and declarative
knowledge.
– Slot values normally amount to declarative knowledge, but a
daemon is in effect a small program. So a slot with a daemon in it
amounts to procedural knowledge.

 Note that a frames system may allow multiple inheritance but,


if it does so, it must make provision for cases when inherited
values conflict.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 29


Frames …
– Advantages:
 Expressive power, easy to set up slots
for new properties and relations
 easy to create specialized procedures

 easy to include default information and


detect missing values
– Disadvantages:
 Difficult to program
 difficult for inference

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 30


A car has 4 wheels, is moved by an engine, and runs on petrol or diesel.

We can now add three slots to the frame.


The last of these has a restriction rather than a specific value.

Name: car Subclass of: thing car subclass_of


thing
with
Slots: wheels: 4,
Name: Value: Restrictions: moved_by:
engine,
wheels 4 fuel:
[value:
moved by engine unknown,
type:
fuel ? petrol or diesel [petrol,diesel]].

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 31


“There is a particular type of car called Toyota, manufactured in Japan.”

 We can add a second frame to our system, with one slot.


We don’t need to repeat the slots and values in the
previous frame: they will be inherited.

‘Toyota’
Name: Toyota Subclass of: car subclass_of
car
Slots: with
Name: Value: Restrictions: made_in:
‘Japan’.
made in Japan

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 32


“There is a particular type of Golf called a TDi, which runs on diesel, has 4
cylinders, and has a 1.8 litre engine.”

Name: TDi Subclass of: Golf


‘TDi’ subclass_of
Slots: ‘Golf’
with
Name: Value: Restrictions:
fuel: diesel,
fuel diesel engine_capacity:
1.8,
engine
capacity 1.8 litres cylinders: 4.

cylinders 4

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 33


Semantic Networks and Logic

 How do we precisely define the semantics of a


frame system or semantic network?
 Modern trend is to have special knowledge
representation languages which look a bit like
frames to users, but which:
– use logic to define what relations mean
– don’t provide the full power of predicate logic,
but a subset that allows efficient inference.
(May not want more than inheritance).

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 34


Summary
 Predicate logic provides well defined language for knowledge
representation supporting inference.
 Semantic nets, frames and objects all allow you to define
relations between objects, including class relations (X isa Y).
 Only restricted inference supported by the methods - that
based on inheritance.
 So.. Jimy is a dog, dogs have 4 legs, so Jimy has 4 legs.
 Frames/Networks/Objects more natural, but only explicitly
support inheritance, and may not have well defined
semantics.
 Current trend is either to just use OO, or to use logic, but
specialises non-logic-based languages still exist.

February 16, 2005 Dr. Al-Amin http://www.geocities.com/alamin_bhuiyan 35


Thank you for enjoying the class.

S-ar putea să vă placă și