KM: The Knowledge MachineA knowledge representation and reasoning system : KM: The Knowledge Machine A knowledge representation and reasoning system
What is KM? : 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
What Do You Do with KM? : 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?
Representing Knowledge : 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 3:30pm, 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
An Informal Knowledge Base : 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 3:30pm
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)
KM for Representing Knowledge : 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)
This Tutorial : 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
Interaction with KM : 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
KM> 123
(123)
KM> (1 + 1)
(2)
KM> (the count of MonteCristo)
(Edmond)
KM> _
Expressions in KM : 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
KM> (*Shiner has (instance-of (Cat)))
(*Shiner)
KM> (*Shiner has (brother (*Kashmir)))
(*Shiner)
KM> (the brother of *Shiner)
(*Kashmir)
KM> (the instance-of of *Kashmir)
(Cat) How does it know?
Knowledge Bases in KM : 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
KM> (load-kb "a-family.km")
Loading a-family.km...
a-family.km loaded!
KM> (the father of *Thomas)
(*Bob)
KM> (the mother of *Thomas)
(*BettyJo)
KM> (*Bryen has (father (*Thomas)))
(*Bryen)
KM> (the grandmother of *Bryen)
(*BettyJo)
KM> (save-kb "a-family2.km")
a-family2.km saved!
Instances : 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"
KM> *Fred
(*Fred)
;;; "1"
KM> 1
(1)
;;; "1 + 1"
KM> (1 + 1)
(2)
1 or, more precisely, a class has a collection of instances associated with it (the class’s extension)
“Creating instances”(existential quantification) : “Creating instances” (existential quantification) We can “create” (assert the existence of) an instance of a particular class
Logic: x.(x) (e.g. x.Cat(x))
KM: (a ) ;;; "A cat."
KM> (a Cat)
(_Cat0) ; _Cat0 is a Skolem individual denoting that cat
;;; "A black cat with a head and a tail."
KM> (a Cat with
(color (*Black))
(parts ((a Head) (a Tail)))
)
(_Cat1) KM> (showme _Cat1)
(_Cat1 has
(instance-of (Cat))
(color (*Black))
(parts ((a Head)
(a Tail))))
(_Cat1)
Slots : Slots Slots relate instances together
Two ways to specify slots:
on existing instances
( has ( ()))
directly on new instances when created
(a with ( ())) KM> (a Car)
(_Car3)
KM> (_Car3 has
(color (*Silver)))
(_Car3)
KM> (showme _Car3)
(_Car3 has
(instance-of (Car))
(color (*Silver)))
KM> (a Car with
(color (*Silver)))
(_Car4)
KM> (showme _Car4)
(_Car4 has
(instance-of (Car))
(color (*Silver)))
Slots : 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."
KM> (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
Superclasses : Superclasses Slots can also give information about classes
The syntax is the same as for instances
( has ( ()))
KM> (Car has
(superclasses (Vehicle))
(subclasses (Hybrid-Car Station-Wagon Sports-Car))
(instances (_Car3 _Car4)))
(Car)
KM> (the subclasses of Vehicle)
(Car)
The Taxonomy (Inheritance Hierarchy) : The Taxonomy (Inheritance Hierarchy) KM> (*Fred has (instance-of (Person)))
KM> (Person has (superclasses (Physobj)))
KM> (Physobj has (superclasses (Thing)))
;;; "Show me the concept taxonomy."
KM> (taxonomy)
Thing
Number
Physobj
Car
Cat
House
Person
I *Fred
I *Joe
…. etc….. Classes can themselves be subclasses of (multiple) other classes
(taxonomy) shows the entire taxonomy
Instance Frames and Simple Queries : Instance Frames and Simple Queries Frames describe objects in the world
list its properties, and relationships to other objects
Queries: Form is (the of