Intro to Knowledge Based Systems - PowerPoint PPT Presentation

About This Presentation
Title:

Intro to Knowledge Based Systems

Description:

Question: Name a painter who lived in a moderate climate. ... Painter(x) Lived-In(x,y) In(y, z) Climate(z, moderate) Adding More Facts. Composer(Palistrina) ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 56
Provided by: elaine8
Category:

less

Transcript and Presenter's Notes

Title: Intro to Knowledge Based Systems


1
Intro to Knowledge Based Systems
CS 343 Elaine Rich
2
The Key Issues
  • What knowledge do we need?
  • How can it be represented?
  • How can we reason with it?
  • Where does it come from?
  • Our sandbox
  • Question answering

3
Stating the Facts
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Question Name a painter ?Painter(x) Le
onardo/x Bind x to Leonardo and we have an
answer
4
Adding More Facts
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Lived-In(Leonardo, Italy) Painter(Rubens) Live
d-In(Rubens, Europe) Question Name an Italian
painter.
5
Adding More Facts
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Lived-In(Leonardo, Italy) Painter(Rubens) Live
d-In(Rubens, Europe) Question Name an Italian
painter. ?Painter(x) ? Lived-In(x, Italy)
6
Adding More Facts
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Lived-In(Leonardo, Italy) In(Italy,Europe) Cli
mate(Europe, moderate) Question Name a painter
who lived in a moderate climate.
7
Adding More Facts
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Lived-In(Leonardo, Italy) In(Italy,Europe) Cli
mate(Europe, moderate) Question Name a painter
who lived in a moderate climate. ?Painter(x) ?
Lived-In(x,y) ? Climate(y, moderate)
8
Adding More Facts
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Lived-In(Leonardo, Italy) In(Italy,Europe) Cli
mate(Europe, moderate) Question Name a painter
who lived in a moderate climate. ?Painter(x) ?
Lived-In(x,y) ? In(y, z) ? Climate(z, moderate)
9
Adding More Facts
Composer(Palistrina) Country(Italy) Lived-In(Leon
ardo, Italy) In(Italy,Europe) Climate(Europe,
moderate) Painter(Rubens) Lived-In(Rubens,
Europe) Question Name a painter who lived in a
moderate climate. ?Painter(x) ? Lived-In(x,y) ?
In(y, z) ? Climate(z, moderate)
10
Making the KB More Flexible
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Lived-In(Leonardo, Italy) In(Italy,Europe) Cli
mate(Europe, moderate) Painter(Rubens) Lived-In(Ru
bens, Europe) ?x,y In(x, y) ? Climate(y,
moderate) ? Climate(x, moderate) Question Name
a painter who lived in a moderate
climate. ?Painter(x) ? Lived-In(x,y) ?
Climate(y, moderate)
11
Another Way to Do It
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Lived-In(Leonardo, Italy) In(Italy,Europe) Cli
mate(Europe, moderate) Painter(Rubens) Lived-In(Ru
bens, Europe) ?x,y,z Lived-In(x, y) ? In(y, z) ?
Lived-In(x, z) Question Name a painter who
lived in a moderate climate. ?Painter(x) ?
Lived-In(x,y) ? Climate(y, moderate)
12
But We Still Havent Said it All
Painter(Leonardo) Town(Anchiano) Country(Italy) Bo
rn-In(Leonardo, Anchiano) In(Anchiano,
Italy) In(Italy, Europe) ?x,y,z Born-In(x, y) ?
In(y, z) ? Born-In(x, z) Question Was
Leonardo born in Europe? ?Born-In(Leonardo,
Europe)
13
Describing in More Generally
Painter(Leonardo) Town(Anchiano) Country(Italy) Bo
rn-In(Leonardo, Anchiano) In(Anchiano,
Italy) In(Italy,Europe) ?x,y,z Born-In(x, y) ?
In(y, z) ? Born-In(x, z) Question Is
Anchiano in Europe? ?In(Anchiano, Europe)
14
Describing in More Generally
Painter(Leonardo) Town(Anchiano) Country(Italy) Bo
rn-In(Leonardo, Anchiano) In(Anchiano,
Italy) In(Italy,Europe) ?x,y,z Born-In(x, y) ?
In(y, z) ? Born-In(x, z) ?x,y,z In(x, y) ?
In(y, z) ? In(x, z) Question Is Anchiano in
Europe? ?In(Anchiano, Europe)
15
But We Still Havent Said Everything about in
Country(Italy) Person(Mike) Visited(Mike,
Italy) In(Italy, Europe) Question Name
someone who visited Europe. ?Person(x) ?
Visited(x, Europe)
16
But We Still Havent Said Everything about in
Country(Italy) Person(Mike) KnowsThePopulationOf(M
ike, Italy) In(Italy, Europe) Question Name
someone who knows the population of
Europe. ?Person(x) ? KnowsThePopulationOf(x,
Europe)
17
Predicate Names
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Lived-In(Leonardo, Italy) In(Italy,Europe) Cli
mate(Europe, moderate) Question Name a painter
who once lived. ?Painter(x) ? Lived(x)
18
The Perils of Long Predicate Names
BearOfVerySmallBrain(Pooh)
19
The Perils of Long Predicate Names
BearOfVerySmallBrain(Pooh)
Name a bear. Is Pooh silly?
20
The Perils of Long Predicate Names
BearOfVerySmallBrain(Pooh) ?b
BearOfVerySmallBrain(b) ? silly(b)
Name a bear. Is Pooh silly?
21
Doing it Right
1. Pooh is a bear Bears are animals animals are
objects, etc.                  Bear(Pooh)       
           ?b Bear(b) ? Animal(b)              
    ?a Animal(a) ? Object(a)2. Pooh has a
very small brain.                 
size(Brain(Pooh)) very(small)3. Brains are
parts of animals an animal has only one.        
?a, b Brain(a) b ?animal(a) ? brain(b) ?
haspart(a,b)4. Animals with brains that are
small (or below) are silly.                 ?a
Size(Brain(a) ? small ? silly(a))5. Every object
has a size.  Sizes are on a scale from Tiny to
Huge. ?x object(x) ? ?s (size(x)
s                 Tiny lt Small lt Medium lt Large
lt Huge                  -2  lt  -1   lt    0  
lt   1   lt  26. The function Very maps a point on
a scale to a more extreme value either positive
or negative.        ?x magnitude(Very(x)) gt x
? sign(Very(x)) sign(x)
22
Implementing The Reasoning Engine
  • Building a theorem prover
  • Unification
  • Representing the facts so they are easy to use
  • An inference procedure that is sound and complete
  • Search algorithm
  • Adding other structure to support common
    operations

23
Reasoning Forward
(1) Painter(Leonardo) (2) Lived-In(Leonardo,
Italy) (3) In(Italy,Europe) (4) Climate(Europe,
moderate) (5) ?x,y In(x, y) ? Climate(y,
moderate) ? Climate(x, moderate) (6) ?x
Climate(x, moderate) ? GrowsIn(x,
boxwood) Question ?Painter(x) ? Lived-In(x,y) ?
GrowsIn(y, boxwood) Reasoning forward Italy/x,
Europe/y in (5) (7) In(Italy, Europe) ?
Climate(Europe, moderate) ? Climate(Italy,
moderate) Italy/x in (6) (8) ?x Climate(Italy,
moderate) ? GrowsIn(Italy, boxwood) Leonardo/x,
Italy/y in (the question) Painter(Leonardo) ?
Lived-In(Leonardo, Italy) ? GrowsIn(Italy,
boxwood)
24
Reasoning Backward
Painter(x) ? Lived-In(x,y) ? GrowsIn(y, boxwood)
Napolean/x,France/y
Rivera/x
Painter(Napolean) ? GrowsIn(France,boxwood)
Leonardo/x
Lived-In(Rivera,y) ? GrowsIn(y, boxwood)
Lived-In(Leonardo,y) ? GrowsIn(y, boxwood)
Italy/y
GrowsIn(Italy, boxwood)
Climate(Italy, moderate)
In(Italy, Europe) ? Climate(Europe, moderate)
25
Unification
A fundamental operation in both of these
processes is matching. In propositional logic,
matching is trivial Example Prove Q ? W
given P P ? Q W
Q ? W Q P True
26
Unification
But in FOPC, it is not so trivial. What should we
do about ?x, y Lived-In(x, y) Lived-In(Leonar
do, Italy) Or ?x P(x, x) P(Leonardo,
Leonardo) P(Leonardo, Rubens) Or ?x P(x,
FatherOf(x)) P(Leonardo, Rubens)
27
Before We Start
Before we consider a set of formulas and begin to
reason with them, we need to standardize the
variables apart Consider ?x, y Lived-In(x,
y) ?x, y Mother-Of(x, y) Although we have used
x and y in both of these formulas, the variables
in these formulas are logically distinct since
they occur inside the scope of quantifiers that
are independent (i.e., neither lies inside the
scope of the other). So an equivalent way to
write these facts is ?x1, y1 Lived-In(x1,
y1) ?x2, y2 Mother-Of(x2, y2)
28
Unification
  • In particular, we need an algorithm that does two
    things given a sentence S and a term T
  • Determine whether T matches some term T in S,
    and
  • Return a substitution that can be applied to the
    remainder of S.
  • Example
  • S ?x,y In(x, y) ? Climate(y, moderate) ?
    Climate(x, moderate)
  • T In(Italy, Europe)
  • The process we will call unification will
    determine that T matches the first term of S and
    it will return the substitution Italy/x,
    Europe/y. When we apply that to the remainder of
    S, we have
  • Climate(Europe, moderate) ? Climate(Italy,
    moderate)

29
The Unification Algorithm
  • Unify(L1,L2)
  • If L1 or L2 is a variable or a constant, then
  • If L1 and L2 are identical, then return nil.
  • Else if L1 is a variable, then if L1 occurs in L2
    then return Fail, else return (L2/L1).
  • Else if L2 is a variable then if L2 occurs in L1
    then return Fail, else return (L1/L2).
  • Else return Fail.
  • If the initial predicate symbols in L1 and L2 are
    not identical, then return Fail.
  • If L1 and L2 have a different number of
    arguments, then return Fail.
  • Set SUBST to Nil.
  • For i ? 1 to number of arguments in L1 do
  • Call Unify with the ith arguments of L1 and L2,
    putting the result in S.
  • If S contains Fail then return Fail.
  • If S is not equal to Nil then
  • Apply S to the remainder of both L1 and L2.
  • SUBST Append(S, SUBST)
  • Return(SUBST)

30
A Simple Unification Example
Painter(Leonardo) Composer(Palistrina) Country(Ita
ly) Lived-In(Leonardo, Italy) In(Italy,Europe) Cli
mate(Europe, moderate) Painter(Rubens) Lived-In(Ru
bens, Europe) ?x,y In(x, y) ? Climate(y,
moderate) ? Climate(x, moderate) Question Name
a painter who lived in a moderate
climate. ?Painter(x) ? Lived-In(x,y) ?
Climate(y, moderate)
31
The Occur Check
Suppose we are trying to unify P(x, x) P(g(x),
g(x)) What happens if we skip the occur check? x
and g(x) unify and yield the substitution
g(x)/x. Now we must apply that substitution to
the remainder of the two sentences g(x) g(g(x))
??? g(g(x)) g(g(g(x))) But if wed
standardized apart the variables before we
started, this wouldnt have been a problem.
32
The Occur Check is Necessary Even with
Standardizing Apart
Suppose we are trying to unify P(x, f(x),
x) P(f(a), a, a) What happens if we skip the
occur check? x and f(a) unify and yield the
substitution f(a)/x. That substitution will be
applied to the remainder of the two expressions,
yielding f(f(a)), f(a) a, a Now these
two will unify, yielding the substitution
f(f(a))/a. To apply it, we must replace all as
in the remaining terms. But that process never
terminates.
33
Most General Unifiers (MGUs)
Suppose we are trying to prove ?x,y A(x, y) ?
B(x, y) Using the fact ?z A(John, z) We unify
A(x, y) with A(John, z). Our algorithm returns
the substitution John/x, z/y. We apply that
substitution to get ?z B(John, z) But we
could also have matched with the substitution
John/x, John/y, and been left trying to
prove B(John, John), which would be harder. The
algorithm we have presented always returns the
most general unifier. The MGU is unique up to
variable name substitution.
34
Unification Is Used With Other Representational
Systems, e.g., Grammars
John likes Coke. John like Coke. I likes
Coke. NUMBER SG ? NUMBER SG NUMBER
SG NUMBER SG ? NUMBER PL Fails NUMBER
SG ? NUMBER NUMBER SG NUMBER SG ?
PERSON 3 NUMBER SG PERSON 3 Two
feature structures can be unified if there is no
conflict between them.
35
Adding Unification to Grammar Rules
The rule S ? NP VP CAT S HEAD 1
STRUCT SUBJECT A1 VP
A2 ? A1 CAT NP
AGREEMENT 2 A2 CAT VP
HEAD 1 AGREEMENT 2
Note The STRUCT feature is used here to record
the tree structure of the constituents as they
are produced.
36
Applying the Grammar Rule
This rule says that we can build an S from two
components, A1 and A2. To apply this rule to two
candidate components X and Y, the parser
must Copy the rule structure to create a new
instance of S. (Unification is destructive and
well need to be able to reuse the rule.) Unify
the feature structure of X with the specification
for A1 on the right side of the rule. This will
succeed if the CAT of X unifies with NP, and if
it succeeds, it will bind 2 to the AGREEMENT
structure of X and A1 to X. Unify the feature
structure of Y with the specification for A2 on
the right side of the rule. This will succeed if
the CAT of Y unifies with VP and if the AGREEMENT
structure of Y unifies with 2, namely the
agreement structure of X. If it succeeds, it
will bind 1 to the HEAD feature of Y and A2 to
Y.
37
Example of Applying the Rule
A1 CAT NP HEAD dogs
STRUCT NOM dogs AGREEMENT NBR
PL PERS 3 A2 CAT VP HEAD ran
STRUCT V ran AGREEMENT
? CAT S HEAD ran STRUCT SUBJECT
CAT NP HEAD dogs
STRUCT NOM dogs
AGREEMENT 2 NBR PL PERS
3 VP CAT VP
HEAD ran STRUCT V ran
AGREEMENT 2
38
Search
?Painter(x) ? ? Lived-In(x,y) ? ? Climate(y,
moderate)
Leonardo/x Rubens/x Sargent/x
America/y Europe/y Italy/y Japan/y
Europe/y Italy/y Japan/y
Which search algorithm should we use?
39
Inheritance
Some specific kinds of reasoning are especially
useful.
Painter(Leonardo) ?x Artist(x) ? Temperamental(x)
40
Inheritance
Some specific kinds of reasoning are especially
useful.
Painter(Leonardo) ?x Artist(x) ?
Temperamental(x) ?x Painter(x) ? Artist(x)
41
Inheritance
Some specific kinds of reasoning are especially
useful.
Painter(Leonardo) ?x Artist(x) ?
Temperamental(x) ?x Painter(x) ? Artist(x)
Person
subclass
Artist subclass Painter
isa Leonardo
42
Alternatives to FOPC
Painter(Leonardo) Composer(Palistrina) ?x
Painter(x) ? Artist(x) ?x Composer(x) ?
Artist(x) ?x Artist(x) ? Temperamental(x) ?x
Person(x) ? ?y Mother-Of(x, y) ?x Person(x) ?
Likes(x, x) Country(Italy) Lived-In(Leonardo,
Italy) In(Italy, Europe) Climate(Europe,
moderate) ?x,y In(x, y) ? Climate(y, moderate) ?
Climate(x, moderate)
We present the facts as a flat list. Theres no
built in grouping, as, for example, all the
things we know about Palistrina.
43
Frame Systems
Organize the facts around the objects in the KB.
(Leonardo isa Painter) (Leonardo has (lived-in
(Italy))) (showme Leonardo) (Leonardo has
(instance-of (Painter)) (lived-in
(Italy)))
44
Classes, Instances, and Slots
  • In a frame system, there are three fundamental
    kinds of objects
  • Instances, e.g., Palistrina, Italy
  • Classes, e.g., Artist, Person, Country, Thing,
    Event
  • Slots, which capture the relationships among
    instances and classes. Examples instance-of,
    lived-in, superclasses, parts

45
Classes
The backbone of any frame system is a hierarchy
of classes, from which properties can be
inherited. Most modern frame systems support
multiple inheritance.
Thing
Living-thing
Person
Artist
Italian
Painter
Leonardo
46
Inference Rules Attach to the Most General Class
to Which They Apply
Inference rules are indexed by the category of
object to which they apply ?x Person(x) ? ?y
Mother-Of(x, y) (Every Person has (mother (a
person))) (showme Person) (Person has
(superclasses (Living-Thing))
(subclasses (Artist Italian)) (instances
(Leonardo))) (Every Person has (mother (a
person))
47
Converting Unary Predicates to Properties
So what do we do with logical expressions that
dont seem to fit into one of these
categories Temperamental(Leonardo) We want to
attach this property to Leonardo. To do that we
need a slot. A natural way to view a slot is as
a binary predicate Lived-In(Leonardo, Italy)
becomes (Leonardo has (lived-in
(Italy))) So we need to create a slot, for
example personality (Leonardo has
(personality (Temperamental))) Or, more
generally (Every Artist has (personality (Tempe
ramental)))
48
What About Consistent Variable Substitution?
This one is easy ?x Person(x) ? Likes(x,
chocolate) (Every Person has (likes
(chocolate))) But what about ?x Person(x)
? Likes(x, x) The way to do this in KM (Every
Person has (likes (self)))
49
Rules with Multiple Antecedents
?x Artist(x) ? Personality(x, temperamental) (eve
ry Artist has (Personality (Temperamental))) ?x
Artist(x) ? Famous(x) ? Personality(x,
temperamental) (every Artist has
((Personality ((if (Self isa FamousPerson)
then Temperamental)))) So weve got if-then
rules but theyre indexed first by one term of
the antecedent (e.g., Artist) and then by the
property mentioned in the conclusion (e.g.,
Personality).
50
Multiple Antecedents and Multiple Variables
?x,y Artist(x) ? Geek(y) ? NotCommunicate(x,
y) (every Artist has (notCommunicate ((the
all-instances of Geek)))) (every Geek has
(notCommunicate ((the all-instances of
Artist))))
51
What About Axioms that Arent Obviously About
Particular Things?
?x,y In(x, y) ? Climate(y, moderate) ? Climate(x,
moderate) Or, more generally ?x,y,z In(x, y) ?
Climate(y,z) ? Climate(x,z)
52
What About Axioms that Arent Obviously About
Particular Things?
?x,y In(x, y) ? Climate(y, moderate) ? Climate(x,
moderate) Or, more generally ?x,y,z In(x, y) ?
Climate(y,z) ? Climate(x,z) In fact, its about
places ?x,y,z Place(x) ? Place (y) ? In(x, y)
? Climate(y,z) ? Climate(x,z) So now we know
where to hang it (every Place has (climate
((the climate of (the Place is-in of Self)))))
53
Slots as Full Fledged Objects
  • Every person has exactly one mother. But a
    person may like many things.
  • If x is a subclass of y then y is a superclass of
    x.
  • If something is blue at time t then it is also
    blue at time t1 unless something specific
    happens to change its color.
  • These are properties of slots (i.e., relations).
    We encode them by treating a slot as an object
    that, in turn, has slots (properties). For
    example
  • (personality has
  • (instance-of (Slot))
  • (domain (Animal))
  • (range (PersonalityTypes)
  • (inverse (InstancesOfPersonalityType)
  • (cardinality (N-to-1)))

54
Can We Axiomatize Some Things Once and For All?
  • Physical objects have mass. Ideas dont.
  • Containers are physical objects that have insides
    and walls.
  • Places cover area on the globe. Some places
    cover subareas of others.
  • If youre in a place, youre inall places
    that overlap it.
  • If youre in a place, youre not in all
    places that dont overlap it.
  • People are physical objects.
  • Etc.

55
Are There Limits to FOPC and Alternatives?
Most x Artist(x) ? Temperamental(x) ?x
Artist(x) ? Temperamental(x) Unless Calm(x) ?x
Painter(x) ? VeryTemperamental(x) ?x Sculptor(x)
? SemiTemperamental(x) ?x,t Painter(x, t) ?
Painter(x, t1) ?x,t Hungry(x, t) ? Hungry(x,
t1) Inside(x)
Write a Comment
User Comments (0)
About PowerShow.com