KM: The Knowledge Machine A knowledge representation and reasoning system - PowerPoint PPT Presentation

1 / 85
About This Presentation
Title:

KM: The Knowledge Machine A knowledge representation and reasoning system

Description:

... (KRL) (like KIF, or ... KM Manuals give the full reference* how to download and run KM details of the syntax logical semantics for the expressions Tutorial ... – PowerPoint PPT presentation

Number of Views:199
Avg rating:3.0/5.0
Slides: 86
Provided by: R51100
Category:

less

Transcript and Presenter's Notes

Title: KM: The Knowledge Machine A knowledge representation and reasoning system


1
KM The Knowledge MachineA knowledge
representation and reasoning system
2
What is KM?
  • A Knowledge Representation Language (KRL)
  • (like KIF, or CycL, or )
  • an interpreter sitting on top of Lisp
  • expressive
  • formal semantics
  • A Reasoning Engine
  • backward chaining
  • automatic classification
  • reasoning with actions (simulation)
  • defaults (inheritance with overrides)
  • Mature
  • Free

3
What Do You Do with KM?
  • Create Knowledge Bases
  • descriptions of things in the world
  • objects, events, properties, relationships
  • descriptions of the rules that allow us to reason
    about things in the world
  • Ask Questions about Knowledge
  • what are the facts?
  • what can be inferred from the facts?
  • what can be inferred from the inferences from
    facts?
  • Run Simulations in the World Described in the KB
  • what would be the state of objects if certain
    events took place?

4
Representing Knowledge
  • What are the kinds of things in the world?
  • Event, Object, Artifact, Device, Computer,
  • What are the real individual things of each kind?
  • PartyAtMyHouseThisSaturday, ThePCInMyOffice
  • What properties hold for all individuals of some
    kind?
  • all events occur at some place and time
  • most computers have hard drives
  • What properties hold for specific individuals?
  • this lecture is at 330pm, your favorite color is
    green
  • How do kinds of things relate to each other?
  • all Computers are Devices, all People have a
    Mother
  • How do individuals relate to each other?
  • Thomas father is Bob, Texas is part of the USA

5
An Informal Knowledge Base
  • Classes
  • Event, Object, Artifact, Device, Computer,
    Person, Place, Hard-Drive are Classes
  • every Event e occurs at a time-of-occ t and
    place-of-occ p
  • The superclass of Computer is Device
  • every Person p1 has a mother p2
  • most Computers c have a part h that is a
    Hard-Drive
  • Instances
  • PartyAtMyHouseThisSaturday is an instance of
    Event
  • ThePCInMyOffice is an instance of Computer
  • ThisLecture is an instance of Event with
    time-of-occ 330pm
  • You is an instance of Person with favorite-color
    green
  • Thomas is an instance of Person with father Bob
    (a Person)
  • Texas is an instance of Place with is-part-of USA
    (a Place)

6
KM for Representing Knowledge
  • English
  • ThePCInMyOffice is an instance of Computer
  • the superclass of Computer is Device
  • Is ThePCInMyOffice a Device?
  • FOPC
  • Computer(ThePCInMyOffice)
  • ?x Computer(x) ? Device(x)
  • Device(ThePCInMyOffice)
  • KM
  • (ThePCInMyOffice has (instance-of (Computer)))
  • (Computer has (superclasses (Device)))
  • (ThePCInMyOffice isa Device)(t)

7
This Tutorial
  • Overview of the KM language and inference
  • based on a detailed script of using KM
  • the examples are toy
  • Not a tutorial in how to do knowledge
    representation!
  • KM Manuals give the full reference
  • how to download and run KM
  • details of the syntax
  • logical semantics for the expressions
  • Tutorial works best if you ask lots of questions!!

http//www.cs.utexas.edu/mfkb/km.html
8
Interaction with KM
  • Interaction with KM read-eval-print
  • User gives KM an expression (assertion/query)
  • KM
  • reads the expression given by the user
  • evaluates it
  • and
  • prints the result

KMgt 123 (123) KMgt (1 1) (2) KMgt (the count of
MonteCristo) (Edmond) KMgt _
9
Expressions in KM
  • The basic expressions in KM are
  • assertions
  • facts and rules about the world
  • queries
  • expressions whose evaluation searches the facts
    and rules

KMgt (Shiner has (instance-of (Cat))) (Shiner) K
Mgt (Shiner has (brother (Kashmir))) (Shiner) K
Mgt (the brother of Shiner) (Kashmir) KMgt (the
instance-of of Kashmir) (Cat)
How does it know?
10
Knowledge Bases in KM
  • KM expressions can be loaded from a file into KM
  • More KM expressions can be evaluated by the
    interpreter, possibly modifying the loaded KB
  • The modified KB can be saved from the KM
    environment into a file

KMgt (load-kb "a-family.km") Loading
a-family.km... a-family.km loaded! KMgt (the
father of Thomas) (Bob) KMgt (the mother of
Thomas) (BettyJo) KMgt (Bryen has (father
(Thomas))) (Bryen) KMgt (the grandmother of
Bryen) (BettyJo) KMgt (save-kb
"a-family2.km") a-family2.km saved!
11
Instances
  • Recall
  • an instance denotes some object in the world
  • a class is a collection of instances1
  • An instance (individual) evaluates to itself

--- instances --- "Fred" KMgt
Fred (Fred) "1" KMgt 1 (1) "1 1" KMgt
(1 1) (2)
1 or, more precisely, a class has a collection of
instances associated with it (the classs
extension)
12
Creating instances(existential quantification)
  • We can create (assert the existence of) an
    instance of a particular class
  • Logic ?x.ltclassnamegt(x) (e.g. ?x.Cat(x))
  • KM (a ltclassnamegt)

"A cat." KMgt (a Cat) (_Cat0)
_Cat0 is a Skolem individual denoting that
cat "A black cat with a head and a
tail." KMgt (a Cat with (color (Black))
(parts ((a Head) (a Tail))) ) (_Cat1)
KMgt (showme _Cat1) (_Cat1 has (instance-of
(Cat)) (color (Black)) (parts ((a Head)
(a Tail)))) (_Cat1)
13
Slots
  • Slots relate instances together
  • Two ways to specify slots
  • on existing instances
  • (ltinstancegt has (ltslotgt (ltvaluegt)))
  • directly on new instances when created
  • (a ltclassnamegt with (ltslotgt (ltvaluegt)))

KMgt (a Car) (_Car3) KMgt (_Car3 has
(color (Silver))) (_Car3) KMgt (showme
_Car3) (_Car3 has (instance-of (Car)) (color
(Silver))) KMgt (a Car with (color
(Silver))) (_Car4) KMgt (showme _Car4) (_Car4
has (instance-of (Car)) (color (Silver)))
14
Slots
  • Slots can relate instances together
  • Slots are themselves frames
  • can specify properties of the slot on these frames

--- slot declarations (optional) ---
"'age' is a slot relating physical objects
(Physobj) to Numbers. A physical object has
at most one age." KMgt (age has
(instance-of (Slot)) (domain (Physobj))
(range (Number)) (inverse
(is-age-of)) name of the inverse slot
(cardinality (N-to-1))) one age
per thing
15
Superclasses
  • Slots can also give information about classes
  • The syntax is the same as for instances
  • (ltclassgt has (ltslotgt (ltvaluegt)))

KMgt (Car has (superclasses (Vehicle))
(subclasses (Hybrid-Car Station-Wagon
Sports-Car)) (instances (_Car3
_Car4))) (Car) KMgt (the subclasses of
Vehicle) (Car)
16
The Taxonomy (Inheritance Hierarchy)
  • Classes can themselves be subclasses of
    (multiple) other classes
  • (taxonomy) shows the entire taxonomy

KMgt (Fred has (instance-of (Person))) KMgt
(Person has (superclasses (Physobj))) KMgt
(Physobj has (superclasses (Thing))) "Show
me the concept taxonomy." KMgt (taxonomy) Thing
Number Physobj Car Cat
House Person I Fred I
Joe . etc..
17
Instance Frames and Simple Queries
  • Frames describe objects in the world
  • list its properties, and relationships to other
    objects
  • Queries Form is (the ltslotgt of ltobjectgt) an
    access path

"Fred is a person." KMgt (Fred has
(instance-of (Person))) "Fred's age is
32." KMgt (Fred has (age (32)))
"Show me the frame representing Fred." KMgt
(showme Fred) (Fred has (instance-of
(Person)) (age (32))) "What is the age of
Fred?" KMgt (the age of Fred) (32)
18
Slot Inverses
  • KM keeps track of inverse relations
    also X?r?Y Y?r-1?X

"Fred owns a car." KMgt (Fred has
(owns ((a Car)))) "What does Fred own?" KMgt
(the owns of Fred) (_Car1)
(Skolem _Car1 created, denoting that car)
"Show me the frame representing that last
car." KMgt (showme (thelast Car)) (_Car1 has
(instance-of (Car)) (owns-of (Fred)))
note the inverse slot (default name is
"ltslotgt-of")
19
Embedded Units and Access Paths
  • Frames can be embedded within frames
  • An access path may be embedded in an access path

--- embedded units --- "Joe is a
person, and owns a red car." KMgt (Joe has
(instance-of (Person)) (owns ((a
Car with (color
(Red)))))) --- access paths --- "What
are the color(s) of the thing(s) which Joe
owns?" KMgt (the color of (the owns of
Joe)) (Red)
20
Embedded Units and Access Paths (cont)
  • An access path will select all values on a slot.
  • (the ltslotgt of ltinstancegt)
  • To select a subset
  • give a class name in the query
  • (the ltclassgt ltslotgt of ltinstancegt)
  • add a filter (generate and test), discussed
    later
  • (allof (the ltslotgt of ltinstancegt) where
    ltfilter-conditiongt)

"Joe is a person, and owns a car and a teddy
bear." KMgt (Joe has (instance-of
(Person)) (owns ((a Car) (a
Teddy-Bear)))) "What does Joe own?" KMgt (the
owns of Joe) (_Car1 _Teddy-Bear2) "What
vehicles does Joe own?" KMgt (the Vehicle owns of
Joe)) (_Car1)
21
Class Frames and Inheritance
  • Can state properties for all members of a class
  • (every ltclassnamegt has (ltslotgt (ltvaluegt)))
  • Each instance of that class acquires (inherits)
    those properties

"People are physical objects" (property of
the class) KMgt (Person has (superclasses
(Physobj))) "Every person
lives in a house." (property of class
members) KMgt (every Person has
(lives-in ((a House)))) "Every house has a
door and a roof." KMgt (every House has
(parts ((a Door) (a Roof)))) "What does Joe
live in?" KMgt (the lives-in of Joe) (_House3)
"What are the parts of the thing which Joe
lives in?" KMgt (the parts of (the lives-in of
Joe)) (_Door4 _Roof5)
22
Self
  • Within a class frame, Self refers to the instance
    inheriting the information.

"Every person likes him/herself" KMgt (every
Person has (likes (Self))) (Person) KMgt (the
likes of Fred) (Fred) KMgt (the likes of
Joe) (Joe) "Every person likes their
favorite color(s)." KMgt (every Person has
(likes ((the favorite-color of
Self)))) (Person) "Fred's favorite color is
blue." KMgt (Fred has (instance-of
(Person)) (favorite-color
(Blue))) (Fred) KMgt (the likes of
Fred) (Fred Blue) KMgt (the Color likes of
Fred)(Blue)
23
Exercises
"All professors have (at least) one car which
is old, is their favorite color, and was made
in Sweden." (Professor has (superclasses
(Person))) (every Professor has (owns (
(a Car with (age (Old))
(color ((the favorite-color of Self)))
(made-by ((a Manufacturer with
(location (Sweden)))))))))
1. Write the KM queries to find - the car
that a professor owns - the age of a
professors car - the location of the
manufacturer of the professors car 2. Create a
KM frame describing the concept of a Car (the Car
class) (every Car has ...)
24
Answers to Exercises
1a. (the Car owns of (a Professor)) 1b. (the age
of (the Car owns of (a Professor))) 1c. (the
location of (the made-by of
(the Car owns of (a Professor)))) 2. For
example... (every Car has (color ((a
Color))) (age ((a Age-Value)))
(made-by ((a Manufacturer)))
(parts ((a Chassis) (a
Engine) (a Fuel-Tank with
(supplies ((the Engine parts
of Self)))))))
25
Exercise
(Electrophoresis has (superclasses
(Process))) (every Electrophoresis has (sample
((a Chemical))) (equipment ((a Separation-unit)
(a Syringe))) (subevents ( (a Remove with
(object ((the sample of Self)))
(location ((the delivery-medium of (the sample of
Self))))) (a Insert with (object
((the sample of Self))) (destination
((the Separation-unit equipment of Self)))
(equipment ((the Syringe equipment of
Self))))))) (Albumin has (superclasses
(Chemical))) (every Albumin has
(delivery-medium ((a Bottle))) (storage-medium
((a Fridge))))
3. What is the result of the query KMgt (the
location of (the Remove subevents of
(a Electrophoresis with (sample
((a Albumin))))))
26
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin))))))
27
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin))))))
KMgt (a Electrophoresis with (sample ((a
Albumin)))) (_Electrophoresis5)
28
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5))
29
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5))
KMgt (showme _Electrophresis5) (_Electrophoresis5
has (instance-of (Electrophoresis)) (sample
((a Albumin))) (subevents ((a Remove)
(a Insert))))
30
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5)) (the location
of _Remove6)
31
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5)) (the location
of _Remove6)
KMgt (showme _Remove6) (_Remove6 has
(instance-of (Remove)) (object ((the sample of
_Electrophoresis5))) (location ((the
delivery-medium of (the sample of
_Electrophoresis5)))) (subevents-of
(_Electrophoresis5)))
32
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5)) (the location
of _Remove6) (the delivery-medium of (the sample
of _Electrophoresis5))
33
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5)) (the location
of _Remove6) (the delivery-medium of (the sample
of _Electrophoresis5))
KMgt (showme _Electrophresis5) (_Electrophoresis5
has (instance-of (Electrophoresis)) (sample
((a Albumin))) (subevents (_Remove6
(a Insert))))
34
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5)) (the location
of _Remove6) (the delivery-medium of (the sample
of _Electrophoresis5)) (the delivery-medium of
_Albumin7)
35
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5)) (the location
of _Remove6) (the delivery-medium of (the sample
of _Electrophoresis5)) (the delivery-medium of
_Albumin7)
KMgt (showme _Alubmin7) (_Albumin7 has
(instance-of (Albumin)) (sample-of
(_Electrophoresis5)) (delivery-medium ((a
Bottle))) (storage-medium ((a Fridge))))
36
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5)) (the location
of _Remove6) (the delivery-medium of (the sample
of _Electrophoresis5)) (the delivery-medium of
_Albumin7) (a Bottle)
37
Answers to Exercises
3. _Bottle8 (i.e., a Skolem instance of
Bottle). (the location of (the Remove
subevents of (a Electrophoresis with (sample ((a
Albumin)))))) (the location of (the Remove
subevents of _Electrophoresis5)) (the location
of _Remove6) (the delivery-medium of (the sample
of _Electrophoresis5)) (the delivery-medium of
_Albumin7) (a Bottle) _Bottle8
38
Simple Data Types
  • KM has numbers, integers, strings, booleans

KMgt (3.1 isa Number) (t) KMgt (3 isa
Integer)(t) KMgt (3.1 isa Integer) NIL KMgt (t
(not NIL))(t) KMgt (f NIL)NIL KMgt ("apocope"
isa String)(t) KMgt (99 100 /- 2)(t) KMgt
(99 100 /- 1 )(t) KMgt (4.99999
5.00000)(t)
39
Rules
  • The expression for a slot-value may be a rule
  • The rule is evaluated when the slot-value is
    queried
  • The tests and result of the rule are themselves
    KM expressions

"A person is a voter if he/she is older than
18." KMgt (every Person has (is-voter
((if ((the age of Self) gt 18) then Yes
else (if ((the age of Self) lt 18)
then No))))) "Is Fred a voter?" Fred is
32, asserted earlier KMgt (the is-voter of
Fred) (Yes) "Joe is 12 years old." KMgt
(Joe has (instance-of (Person))
(age (12))) (Joe) "Is Joe a voter?" KMgt
(the is-voter of Joe) (No)
"Is some generic person a voter?" KMgt (the
is-voter of (a Person))NIL
40
Exercise
4. Complete the expression on the brightness
slot for the concept of a Light, so that the
result depends on the lights switch position.
(every Light has (part ((a Switch with
(position ((a PositionValue)))))
(brightness (...))) (Up has (instance-of
(PositionValue))) (Down has (instance-of
(PositionValue))) (Bright has (instance-of
(BrightnessValue))) (Dark has (instance-of
(BrightnessValue))))
41
Answers to Exercises
4. (every Light has (part ((a Switch with
(position ((a PositionValue))))))
(brightness ( (if ((the position of (the
Switch part of Self)) Up) then
Bright else (if ((the position of (the
Switch part of Self)) Down) then
Dark))))) Note that if the position is unknown,
then the brightness will be unknown also (which
is what we want).
42
Complex Types
  • KM also has sets, sequences, bags

"Jason has two favorite colors" KMgt (Jason
has (favorite-color (Blue Green))) (Jason) KMgt
(the favorite-color of Jason)(Blue
Green) "So does Mike"KMgt (Mike has
(favorite-color ((set Blue Green)))) (Mike) K
Mgt (the favorite-color of Mike)(Blue
Green) "Mike, John and Jason finished 1st,
2nd and 3rd"KMgt (a Tournament with
(finishers ((seq Mike John Jason))))(_Tournam
ent6) "Mike had scores of 66, 67, 73 and
67KMgt (Mike has (round-score ((bag 66 67 73
67))))(Mike)
43
Arithmetic
  • KM has infix operators , -, , /,
  • Also has arithmetic slots (the sum of .), etc.
  • sum, difference, product, quotient, and others

"What is 1 1?" KMgt (1 1) (2) "A
person's age in days is their age in years
times 365." KMgt (every Person has
(age-in-days (((the age of Self)
365)))) (Person) "What is Fred's age in
days?" KMgt (the age-in-days of Fred) (11680)
"What was Mike's total score last week? KMgt
(Mike has (round-score ((bag 66 67 73
67))))(Mike) KMgt (the sum of (the round-score
of Mike))(273)
44
Set Expressions
  • Procedurally, KM iterates over a set of values
  • Two main iterators
  • (allof ltsetgt where ltfilter-conditiongt)
  • (forall ltsetgt where ltfilter-conditiongt
    ltexpressiongt)
  • Keyword It denotes the value in each iteration

"Show me every person in the KB so
far?" KMgt (every Person) (Joe Fred) or
equivalently KMgt (the all-instances of
Person) (Joe Fred) "Which people are over
18?" KMgt (allof (the all-instances of Person)
where ((the age of It) gt
18)) (Fred) "What is the favorite color(s)
of the people over 18?" KMgt (forall (the
all-instances of Person) where ((the
age of It) gt 18) (the favorite-color
of It)) (Blue)
45
Aside Tracing in KM
KMgt (Lily has (instance-of (Person))
(favorite-color (Lilac)) (age (21)))(Lily) KMgt
(trace)(Tracing of KM switched on) KMgt (forall
(the all-instances of Person) where ((the age of
It) gt 18) (the favorite-color of
It)) 1 -gt (forall (the all-instances of Person)
where ((the age of It) gt 18) (the
favorite-color of It)) 2 -gt (the all-instances
of Person) 2 lt- (Joe Fred Lily)
(the all-instances of Person) 2 -gt ((the
age of Joe) gt 18) 3 -gt (the age of Joe) 3
lt- (12) (the
age of Joe) 2 lt- FAIL!
((the age of Joe) gt 18) 2 -gt ((the
age of Fred) gt 18) 3 -gt (the age of Fred) 3
lt- (32) (the
age of Fred) 2 lt- (t)
((the age of Fred) gt 18) 2 -gt (the
favorite-color of Fred) 2 lt- (Blue)
(the favorite-color of
Fred) 2 -gt ((the age of Lily) gt 18) 3 -gt
(the age of Lily) 3 lt- (21)
(the age of Lily) 2 lt- (t)
((the age of Lily)
gt 18) 2 -gt (the favorite-color of Lily) 2 lt-
(Lilac) (the
favorite-color of Lily) 1 lt- (Blue Lilac)
(forall ... (Blue
Lilac) KMgt (untrace)(Tracing of KM switched
off)
46
Whats Wrong with Set Expressions?
  • Two main iterators
  • (allof ltsetgt where ltfilter-conditiongt)
  • (forall ltsetgt where ltfilter-conditiongt
    ltexpressiongt)
  • Keyword It denotes the value in each iteration
  • Hint
  • if ltexpressiongt can be any KM expression, could
    it be an iterator?
  • could ltsetgt and ltfilter-conditiongt contain
    iterators?

47
Set Expressions with Variables
  • A slightly more general form allows for
    nestediterators
  • (allof ltvargt in ltsetgt where ltfilter-conditiongt)
  • (forall ltvargt in ltsetgt where ltfilter-conditiongt
    ltexpressiongt)

"Which people are over 18?" KMgt (allof ?x in
(the all-instances of Person) where
((the age of ?x) gt 18)) (Fred Lily) "What
is the favorite color(s) of the people over
18?" KMgt (forall ?y in (the all-instances of
Person) where ((the age of ?y) gt
18) (the favorite-color of
?y)) (Blue Lilac) "What things do people
over 18 own that are their favorite colors?" KMgt
(forall ?p in (the all-instances of Person)
where ((the age of ?p) gt 18)
(allof ?t in (the owns of ?p)
where ((the color of ?t) (the favorite-color of
?p)) ) ) (_Car11 _House13)
48
Unification
"Johanne likes some cute puppy"KMgt (Johanne
has (likes ((a Puppy with
(trait (cute)))))) (Johanne)
"What puppy does Johanne like? KMgt (the likes
of Johanne) (_Puppy25) "Victor is a
puppy" KMgt (Victor has (instance-of
(Puppy)) (color (brown))) (Victor)
  • Is it possible that _Puppy25 and Victor are the
    same puppy?
  • What would we then know about Victor?

49
Unification
  • The assertion of equality of two objects
  • The merging of data structures associated with
    instances

(_Person3 has (parts ((a Brain))) (name
("Albert"))) )
(_Student4 has (parts ((a Body))) (gpa
(9.6))) )
(_Student4 has (parts ((a Brain) (a
Body))) (name ("Albert"))) (gpa (9.6)) )
50
Vertical Unification (Inheritance)
  • Inheritance is a kind of unification
  • An instance of a class is the unification of
    anonymous instances of all its ancestor classes

(every Living-Thing has (parts ((a Body))) )
_Living-Thing832
superclasses
(every Person has (parts ((a Brain))) )
_Person834
superclasses
(every Student has (gpa ((a Number))) )
_Student836
isa
(_Student4 has (parts ((a Brain) (a
Body))) (gpa ((a Number))) )
_Student4 _Living-Thing832 _Person834
_Student836 _Student4
51
Multiple Inheritance and Unification
  • If several frames contribute to a slots values,
    KM will unify the different sets of values
    together
  • set unification is heuristic, not deductive
  • unifies two instances together
  • unifies two sets together
  • ? and ? check if unification is possible
    (without doing the unification)

Can a pet and a fish unify? KMgt ((a Pet) ?
(a Fish)) (t) Unify these two objects
together KMgt ((a Pet) (a Fish)) (_Pet1) KMgt
(showme _Pet1) (_Pet1 has (instance-of (Pet
Fish))) Unify these two sets together KMgt
(((a Cat) (a Dog)) ((a Cat) (a
Rabbit))) (_Cat1 _Dog2 _Rabbit3)
52
Inheritance and Unification Example
"Every big car has a large engine." KMgt
(every Big-Car has (parts ((a Engine
with (size
(Large)))))) "Every powerful car has a
powerful engine." KMgt (every Powerful-Car has
(parts ((a Engine with
(power (Lots)))))) "Suburbans are
both big and powerful cars." KMgt (Suburban has
(superclasses (Big-Car Powerful-Car))) "What
are the parts of a Suburban?" KMgt (the parts of
(a Suburban)) (COMMENT (_Engine7 _Engine8)
unified to be _Engine7) (_Engine7) KMgt (showme
(thelast Engine)) (_Engine7 has (instance-of
(Engine)) (size (Large)) (power (Lots))
(parts-of (_Suburban6)))
Here KM decides the 2 engines are coreferential
because (i) same class (or ones classes
subsumes the others) (ii) unification
doesnt violate constraints
Note result of unification Engine is both
large and has lots of power.
53
Inheritance Unification Another Example
  • Again, the different contributing value sets are
    unified together.

"Every person has two legs and a head." KMgt
(every Person has (parts ((a Head) (a
Leg) (a Leg)))) (Person) "Fred has a
leg." KMgt (Fred has (parts ((a
Leg)))) (Fred) "What are the parts of
Fred?" Note two legs -- KM unifies one of
the two legs on Person with the leg on Fred
KMgt (the parts of Fred) (_Leg9 _Head10 _Leg11)
54
Defeating Inheritance
  • There are several tools in KM to control
    unification
  • One powerful tool is inherit-with-overrides

KMgt (birth has (domain (Animal))
(instance-of (Slot)) (cardinality
(N-to-1))) (birth) KMgt (every Mammal has (birth
(Live))) (Mammal) KMgt (Platypus has
(superclasses (Mammal))) (Platypus) KMgt (every
Platypus has (birth (Egg))) (Platypus) KMgt (the
birth of (a Platypus)) ERROR! Unification (Egg
Live) failed! NIL KMgt (birth has
(inherit-with-overrides (t))) (birth) KMgt (the
birth of (a Platypus)) (Egg)
55
Constraints
  • Can attach constraints to a slot
  • constrains the allowed values on that slot
  • checked when that slot is queried
  • Two types
  • value constraints applies to each value in turn
  • (every Witch has (pet ((must-be-a Cat with (color
    (Black))))))
  • (every Witch has (pet ((mustnt-be-a Dog))))
  • (every Sedan has (doors ((ltgt 3))))
  • (a Cat with (color ((constraint (TheValue
    Black)))))
  • (a Witch with (pet ((constraint ((the color of
    TheValue) Black)))))
  • set constraints applies to the set of values
  • (every Animal has (parts ((at-least 2 Leg))))
  • (every Human has (parts ((at-most 2 Leg))))
  • (every Bipod has (parts ((exactly 2 Leg))))
  • (a Triumvirate with (member ((set-constraint
    ((the number of TheValues) 3)))))

56
Value Constraints
  • Checks each value in turn, when the slot is
    queried
  • keyword TheValue denotes the value being tested
  • must-be-a constraints are enforced (not just
    checked)

"A person's friends must all be of class
Person." KMgt (every Person has
(friends ((must-be-a Person)))) "A person
cannot marry him/herself." (ltgt means "cannot
equal") KMgt (every Person has (spouse ((ltgt
Self)))) "Fred's spouse is himself (and
Smilla)." KMgt (Fred has (spouse (Fred
Smilla))) KMgt (showme Fred) (Fred has
(instance-of (Person)) (age (32))
(favorite-color (Blue)) (spouse (Fred
Smilla)) (spouse-of (Fred))) (Fred)
"Who is Fred's spouse?" The constraint violation
is detected at query time KMgt (the spouse of
Fred) ERROR! Constraint violation! Discarding
value Fred (conflicts with (ltgt Fred))
57
Set Constraints
  • Checks the entire set of values on a slot
  • Keyword TheValues denotes the set being tested
  • Useful for at most / at least constraints

"Every Airplane has exactly two wings." KMgt
(every Airplane has (parts ((exactly
2 Wing)))) (Airplane) General value
constraints TheValue denotes the value being
checked. KMgt (every Person has
(leg-parts ((constraint (TheValue isa
Leg))))) General set constraints TheValues
denotes the set of values being checked. KMgt
(every Person has (leg-parts
((set-constraint ((the number of TheValues) lt
2)))))
58
Defined Classes and Automatic Classification
  • Defining properties of a class
  • Any object with these properties is in that class
  • (every ltclassnamegt has-definition
    (instance-of (ltgeneralclassgt)) (ltslotgt
    (ltvaluegt)) ...)
  • If new info found about an instance, its classes
    are re-checked

"A Texan is a person who lives in Texas,
AND every person living in Texas is a Texan." KMgt
(every Texan has-definition
(instance-of (Person)) (lives-in
(Texas))) KMgt (every Texan has (likes
(Willie))) KMgt (the instance-of of
Fred) (Person) KMgt (Fred has (lives-in
(Texas))) (COMMENT Fred satisfies definition
of Texan,) (COMMENT so changing Fred's classes
from (Person) to (Texan)) (Fred) KMgt (the
instance-of of Fred) (Texan) KMgt (the likes of
Fred) (Willie)
59
Care with Automatic Classification
  • KM is eager with automatic classification
  • as soon as an instance is created or modified, KM
    (re)checks all classification rules

KMgt (Island-Country has (superclasses
(Country))) (Island-Country) KMgt (every
Island-Country has-definition
(instance-of (Country)) (neighbors
((exactly 0 Country)))) (Island-Country) KMgt
(USA has (instance-of (Country))) (COMMENT USA
satisfies definition of Island-Country,) (COMMENT
so changing USA's classes from (Country) to
(Island-Country)) (USA) KMgt (Canada has
(instance-of (Country))
(neighbors (USA))) (Canada) KMgt (Spain has
(instance-of (Country))
(neighbors (Portugal))) (COMMENT Spain
satisfies definition of Island-Country,) (COMMENT
so changing Spain's classes from (Country) to
(Island-Country)) (Spain)
60
Exercise
  • 5. Create KM frames defining
  • the concept of a RedWine (a red wine)
  • a bachelor
  • a square

61
Answers to Exercise
5a. (every RedWine has-definition
(instance-of (Wine)) (color
(Red))) 5b. (every Bachelor has-definition
(instance-of (Man)) (spouse
((exactly 0 Thing)))) 5c. (every Square
has-definition (instance-of
(Rectangle)) (length ((the width of
Self))) (width ((the length of Self))))
62
Situations
  • A situation is a partition of the knowledge base
  • Mainly to represent snapshots of the world at
    different times
  • Facts can differ in each situation
  • But each situation acquires all the facts of the
    global situation
  • Situations can be temporally ordered
  • Can define actions which change a situation, and
    thus perform simulation

Global
supersituations
supersituations
subsituations
subsituations
import
supersituations
subsituations
prev-situation
prev-situation
_Situation1
_Situation2
_Situation3
project
project
next-situation
next-situation
63
Situations Fluents and Non-Fluents
  • Non-fluent Fact is universally true
  • Inertial-fluent Fact can propagate from one
    situation to the next
  • (Non-inertial) Fluent Fact does not propagate

"Mike was born in 1977." KMgt (Mike has
(birthdate (1977))) (Mike)
"birthdate is a constant ('non-fluent')" KMgt
(birthdate has (instance-of (Slot))
(cardinality (N-to-1)) (fluent-status
(Non-Fluent))) "age may vary, but by
default will remain unchanged." KMgt (age has
(instance-of (Slot)) (cardinality
(N-to-1)) (fluent-status
(Inertial-Fluent)))
64
Situations Projection (example)
"Create a new situation." KMgt
(new-situation) (COMMENT Changing to situation
_Situation24) "In this situation, Mike is 27
years old." _Situation24 KMgt (Mike has (age
(27))) "What is Mike's age in this
situation?" _Situation24 KMgt (the age of
Mike) (27) "Create and go to a new
situation, the temporal successor of this
one." _Situation24 KMgt (next-situation) (COMMENT
Changing to situation _Situation25) "What
is Mike's age in this situation?" _Situation25
KMgt (the age of Mike) (COMMENT Projected Mike
age (27) from _Situation24 to
_Situation25) (27)
65
Situations Projection (cont)
  • For inertial fluents, facts only propagate from
    one situation to the next if it is consistent to
    do so.

_Situation25 KMgt (next-situation) (COMMENT
Changing to situation _Situation26) (_Situation26)
"In this situation, Mike is 28 years
old." _Situation26 KMgt (Mike has (age
(28))) (Mike) "What is Mike's age in this
situation?" Note '27' is not projected, as
'28' overrides it and this slot cannot have
multiple values. _Situation26 KMgt (the age of
Mike) (28)
66
Querying Situations from the Global Situation
  • Can also query one situation from another
  • (in-situation ltsituationgt ltquerygt)
  • KM remembers each situation (so can query over
    them all)

"Exit this situation, and return to the
'global situation'." _Situation26 KMgt
(global-situation) (COMMENT Changing to
situation Global) (t) "In the last
situation created, what was Mike's age?" KMgt
(in-situation (thelast Situation) (the age of
Mike)) (28) "In which situations was Mike
27?" KMgt (allof (the all-instances of Situation)
where (in-situation It ((the age of
Mike) 27))) (_Situation25 _Situation24)
67
Specifying Actions
  • Actions define how an event changes the world
  • They specify
  • preconditions facts which must be true for the
    action to be performable
  • add-list, del-list facts which become true/false
    as a result of the action
  • Facts are stated as triples (frame-slot-value
    structures)

"Every switching on is an Action." KMgt
(Switching-On has (superclasses
(Action))) (Switching-On) "Every switching
on changes a switch's position from down to
up." KMgt (every Switching-On has
(object ((a Switch))) (del-list
((triple (the object of Self) position Down)))
(add-list ((triple (the object of
Self) position Up)))) (Switching-On)
68
Simulation
  • do-and-next will execute an action in a
    situation
  • creates a new situation
  • updates the facts in it, according to the action

"Create a new situation." KMgt
(new-situation) "There is a switch whose
position in this situation is
down." _Situation27 KMgt (a Switch with
(position (Down))) (_Switch28) "Create and
enter the situation resulting from switching that
switch on." _Situation27 KMgt (do-and-next
(a Switching-On with
(object (_Switch28)))) (_Situation30)
"What is the position in this new
situation of that switch?" _Situation30 KMgt
(the position of _Switch28) (Up)
69
Simulation (cont)
  • again, previous situations can be queried and
    quantified over

--- previous situations are preserved
--- "In the previous situation, what was the
position of the switch?" _Situation30 KMgt
(in-situation (the
prev-situation of (curr-situation))
(the position of _Switch28)) (Down)
"In which situations was the switch
down?" _Situation30 KMgt (allof (the
all-instances of Situation)
where (in-situation It
((the position of _Switch28)
Down))) (_Situation27)
70
Another Example of Simulation
  • (Open has (superclasses (Action)))
  • (every Open has
  • (object ((a Door)))
  • (pcs-list ((triple (the object of Self)
    lock-state Unlocked)))
  • (add-list ((triple (the object of Self)
    door-state Open)))
  • (del-list ((triple (the object of Self)
    door-state Closed)))
  • )
  • (lock-state has (instance-of (Slot)) (cardinality
    (N-to-1)))
  • (door-state has (instance-of (Slot)) (cardinality
    (N-to-1)))
  • _Situation1 KMgt (a Door with (lock-state
    (Unlocked)))
  • (_Door2)
  • _Situation1 KMgt (a Open with (object (_Door2)))
  • (_Open3)
  • _Situation1 KMgt (do-and-next _Open3)

71
Another Example of Simulation
  • _Situation4 KMgt (a Door)
  • (_Door5)
  • _Situation4 KMgt (do-and-next (a Open with
    (object (_Door5))))
  • (COMMENT Assuming (triple _Door5 lock-state
    Unlocked), to do action _Open6...)
  • (COMMENT Changing to Situation _Situation7)
  • (_Situation7)
  • _Situation7 KMgt (in-situation _Situation4 (the
    lock-state of _Door5))
  • (Unlocked)
  • _Situation7 KMgt (a Door with (lock-state
    (Locked)))
  • (_Door8)
  • _Situation7 KMgt (do-and-next (a Open with
    (object (_Door8))))
  • (do _Open9) Can't do this action as it would be
    inconsistent to assert precondition(s)
  • (triple _Door8 lock-state Unlocked)
  • NIL

72
Text Generation
  • A special type of instance is a sequence
  • (seq v1 vn)
  • Text strings can be built up as a sequence of
    fragments

KMgt (every Remove has (text ( (seq
"Remove" (the object of Self) "from" (the
location of Self))))) "What is are the text
for a remove of a sample from a box? KMgt (the
text of (a Remove with
(object ((a Sample))) (location ((a
Box))))) ((seq "Remove" _Sample14 "from"
_Box15)) "Make a sentence from these
fragments." KMgt (make-sentence (the text
of (a Remove with
(object ((a Sample))) (location
((a Box)))))) ("Remove the sample from the box.")
73
Slot Hierarchies
  • Slots can have subslots
  • Values of subslots are also values of the
    superslot
  • values propagate up)

"parts has subslots mechanical-parts." KMgt
(parts has (instance-of (Slot))
(subslots (mechanical-parts
structural-parts))) (parts) "Every airplane
has a jet engine as one of its mechanical
parts and a fuselage as one of its
structural parts." KMgt (every Airplane has
(mechanical-parts ((a Jet-Engine)))
(structural-parts ((a Fuselage)))) (Airplane)
"What are the parts of an airplane?" KMgt (the
parts of (a Airplane)) (_Jet-Engine23
_Fuselage24)
74
Prototypes Example
  • KMgt (a Airplane with (has-part ((a Wing) (a
    Wing))))(_Airplane9)
  • KMgt (showme _Airplane9)(Airplane9 has
    (instance-of (Airplane)) (has-part ((a Wing)
    (a Wing))))
  • KMgt (showme Airplane)(Airplane has
    (superclasses (Device)) (instances
    (_Airplane9)))
  • KMgt (the has-part of (a Airplane))NIL

75
Prototypes Example
  • KMgt (a-prototype Airplane)(_ProtoAirplane11)
  • prototype-mode KMgt (_ProtoAirplane11 has
    (has-part ((a Wing) (a Wing))))(_ProtoAirplane11)
  • prototype-mode KMgt (end-prototype)
  • KMgt (showme Airplane)(Airplane has
    (superclasses (Device)) (instances (_Airplane9
    _Airplane10
    _ProtoAirplane11)) (prototypes
    (_ProtoAirplane11)))
  • KMgt (the has-part of (a Airplane))(COMMENT
    Cloned _ProtoAirplane11 -gt _Airplane15
    to find (the
    has-part of _Airplane14))(COMMENT (_Airplane14
    _Airplane15) unified to be _Airplane14)(Wing16
    _Wing17)

76
KM Some Outstanding Issues
  • Reasoning can get complex, and hard to debug
  • No full truth maintenance
  • Need for defaults added during RKF
  • Heuristic unification can sometimes get it wrong
  • Knowledge engineer can provide guidance
  • Use of prototypes important for KM in Shaken
  • Explanations
  • store which rule derived which fact
  • being extended to store the proof tree for a
    fact

77
A KM Concept Library
  • Insight even domain-specific representations
    contain common abstractions
  • Approach we build a library consisting of
  • a small hierarchy of reusable, composable,
    domain-independent concepts (components)
  • a small vocabulary of relations to connect them
  • then domain experts build representations by
    instantiating and composing these components

78
A Library of Components
small
  • easy to learn
  • easy to use
  • broad semantic distinctions (easy to choose)
  • allows detailed pre-engineering

79
Component Library Contents
  • actions things that happen, change states
  • Enter, Copy, Replace, Transfer, etc.
  • states relatively temporally stable events
  • Be-Closed, Be-Attached-To, Be-Confined, etc.
  • entities things that are
  • Substance, Place, Object, etc.
  • roles things that are, but only in the context
    of things that happen
  • Container, Catalyst, Barrier, Vehicle, etc.

80
Library Contents
  • relations between events, entities, roles
  • agent, donor, object, recipient, result, etc.
  • content, part, material, possession, etc.
  • causes, defeats, enables, prevents, etc.
  • purpose, plays, etc.
  • properties between events/entities and values
  • rate, frequency, intensity, direction, etc.
  • size, color, integrity, shape, etc.

81
Informal Representation
  • A person throws a ball toward the door of a
    room. The ball passes through the door and into
    the room

82
KM CLib Representation
  • (a Activity with (agent ((a Person)))
    (object ((a Ball))) (first-subevent ((the
    Throw subevent of Self))) (subevent ( (a
    Throw with (object ((the Ball object of
    Self))) (destination ((a Door)))
    (next-event ((the Move-Into subevent of Self)))
    ) (a Move-Into with (object
    ((the Ball object of Self))) (base ((a
    Room with (has-region (
    (the Door destination of
    (the Throw subevent of
    Self))))))) ) )))

83
Component Library Adds
84
Component Library Adds
  • The Ball and the Person must be together at t0
  • The Ball must be held by the Person at t0
  • The Ball must not be otherwise Restrained
  • The path to the Door must not be Blocked
  • At t1 the Ball is at the Door and no longer at
    the Person
  • At t1 the Ball is outside the Room but not shut
    out of it
  • The Door must not be Closed
  • The Ball passes through the Doorway
  • At t2 the Ball is inside the Room and no longer
    outside
  • At t2 the Room has the Ball among its contents
  • Blocked paths can be unblocked
  • Closed Doors can be Opened

85
http//www.cs.utexas.edu/users/mfkb/RKF/tree/
Write a Comment
User Comments (0)
About PowerShow.com