Representation of Knowledge
• Overview
• Meaning of knowledge
• Methods of knowledge representation
– Backus- Naur form – Rules
– Semantic Nets
– Object-Attribute-Value – Schema (Frames, Scripts) – Logic
2
• know the basic principles and concepts for
knowledge representation
– knowledge - information - data
– meaning
• be familiar with the most frequently used
knowledge representation methods
– logic, rules, semantic nets, schemata
• differences between methods, advantages, disadvantages, performance, typical scenarios
• understand the relationship between
knowledge representation and reasoning
– syntax, semantics
– derivation, entailment
• apply knowledge representation methods
– usage of the methods for simple problems
4
• Epistemology
• Types of knowledge
• Hierarchy of knowledge
Meaning of Knowledge
2
Epistemology: The study of knowledge
EPISTEMOLOGY ( Gr. episteme, "knowledge"; logos,
"theory"), branch of philosophy concerned with the theory of knowledge. The main problems with which pistemology is concerned are the definition of knowledge and related concepts, the sources and criteria of knowledge, the kinds of knowledge possible and the degree to which each is
certain, and the exact relation between the one who knows and the object known. [Infopedia 1996]
6 Epistemology Philosophic Theories A Priori Knowledge A Posteriori Knowledge e.g. all triangles
have 180 degrees
e.g. the light is green
Meaning of Knowledge
4
• Types of knowledge
– a priori knowledge
• comes before knowledge perceived through senses • considered to be universally true
– a posteriori knowledge
• knowledge verifiable through the senses • may not always be reliable
8
Meaning of Knowledge
5
• Type of knowledge (con’t)
– procedural knowledge
• knowing how to do something
– declarative knowledge
• knowing that something is true or false
– tacit knowledge (Unconscious Knowledge)
Meaning of Knowledge
6
• Rule 1: IF Rain THEN Bring Raincoat
• Rule 2: IF Rain THEN Bring Umbrella
• Meta Rule1: Try Rule 2 First
Meta Knowledge Knowledge Information Data Noise
(rules about rules) (rules + facts)
(facts) (facts) Knowledge Hierarchy
10
Meaning of Knowledge
7
13 71 78 76 68 32 52 51 56 43 00 15 1) Noise:
For people without it
2) Data:
For people with care about it
3) Information:
1. Group the number by two’s.
2. Ignore any two-digit numbers less than 32. 3. Substitute the ASCII characters.
Gold 438+ 4) Knowledge:
IF Gold is less than 500 and the price is rising (+) Then buy gold
5) Meta knowledge Example:
Meaning of Knowledge
8
Conventional
Programming
Knowledge-Based
Systems
Algorithms + Data Structures = Programs Knowledge + Inference = Expert System N. Wirth12
Representation Methods
1
• Backus- Naur form
• Production Rules
• Semantic Nets
• Object-Attribute-Value
• Schema (Frames, Scripts)
• Logic
Backus-Naur form
(BNF)
• Define the syntax of a language
e.g. <sentence>::=<subject><verb><end-mark> <subject>::=I | You | We <verb>::=left | came <end-mark>::=. | ? | !
• Parse Tree
sentence camesubject verb end-mark You
14
Production Rules
IF your spouse is in a bad mood THEN don’t appear happy
Premise LHS Antecedent condition Conclusion action RHS chunk IF p1 THEN p2 IF p2 THEN p3 IF p2 THEN p4 p1 p2 p2 p3 p4
IF someone pretends to be unhappy THEN he will be in bad mood
IF your spouse is in a bad mood THEN pretend to be unhappy
IF two persons are both in bad mood THEN they will fight each other
IF two persons fight each other THEN one of them will die
16
Production Rules
• Match
• Conflict Resolution (Rule Selection)
• Fire
• Example:
Facts: A1=1, B1=2, IF A1=1 AND B1=3 THEN C =5 IF A1=1 AND B1=2 THEN C =6 IF A1=1 THEN D =7 IF A1=4 THEN D =8 IF B1=2 THEN E =9 IF A1=1 AND C=6 THEN F =10Architecture of a production System
Rules Match (Conflict Set) Conflict resolution Fire (act) Modification Facts18
AGENDA: A list of matched rules
KB (rules) Inference Engine AGENDA Working Memory (facts) Explanation facility Knowledge Acquisition facility User Interface
•
Advantages of Rule-based Systems:
1. Modular Nature:
– Easy to increase Knowledge
2. Similar to human cognitive process 3. Explanation facilities:
– Example 1:
IF A AND B THEN C IF C AND D THEN E Why (E)?
Because Explain (C) and Explain (D) Why (D)?
D is an input fact. Why (C )?
20
– Example 2:
Rule 1: IF h-fever AND r-spot THEN Danger-fever
Rule 2: IF temperature >38 THEN h-fever = true Why Danger fever?
Because Explain( h-fever) AND Explain(r-spot) According to Rule 1:
If a person has high fever and
a person has red spots over his body then the person may have Danger fever Why high fever?
According to Rule 2:
If a person’s temperature exceed 38 degree then the person has high fever.
Semantic Net
• Propositional Net
• Associative Net
• A label, directed graph
• Node: object
22 sister-of Ann wife-of husband-of wife-of husband-of
Bill Carol David
mother-of father-of mother-of father-of husband-of mother-of father-of Susan Tom John relationship
23
General Net
San Francisco Chicago New York
Los Angeles
24
IS-A and A-KIND-OF
• Special kinds of relationship in semantic nets
• IS-A:
– Related an instance of individual to a generic
class
• AKO:
– Related a generic class to another generic class
• Superclass and Subclass
• Attribute, Value, Property
• Inheritance
Example
Goodyear
aircraft
round balloon Propeller
driven jet
ellipsoidal blimp special DC-3 Concorde
Spirit of Air
has-shape DC-9
has-shape
AKO AKO AKO
AKO AKO AKO AKO AKO AKO
26 General purpose computer Multi processo r My count-logic board My calculato r Micro computer mini computer mainfram e Super computer dedicate d Board-level Compute r-on-a-chip Single processo r 80486 SX IBM S/34 VAX 6500 Weather monitor-predict system Computi ng system purpose Internal process AKO
AKO AKO AKO AKO AKO
purpose
purpose
purpose
ISA ISA ISA
Internal
process Internal process
Internal process
Semantix Net Example
Gaul Astérix Obélix Idéfix Dog Abraracourcix Panoramix Ordralfabetix Cétautomatix barks-at Human AKO28
Semantix Net Cheats
• colors
– should properly be encoded as separate nodes with relationships to the respective objects
• font types
– implies different types of relationships
– again would require additional nodes and relationships
• class relationships
– not all dogs live with Gauls
– AKO (a-kind-of) relationship is special (inheritance)
• instances
– arrows from individual humans to the class Human omitted • assumes that AKO allows inheritance
• directionality
Object-Attribute-Value Triples
(OAV)
• especially useful for representing facts
• For only a single object:
Object
Attribute
Value
apple apple apple grapes grapes grapes color type quantity color type quantity red mcintosh 100 red seedless 500
30
Example
Wheel: 4 Function:run . . . Door: 3 . . . Door: 4 . . . Carry: people Size: small Carry: goods Size: bigPrice: $$$ Price: $$$ Price: $$$ Price: $$$
year: 1998 Owner: gjh Year: 1992 Owner: crt Car Object Attribute Value AKO AKO AKO AKO AKO AKO … R9 Civic IS-A IS-A …
OAV-Triples
• object-attribute-value triplets
– can be used to characterize the knowledge in a semantic net
– quickly leads to huge tables
Object
Attribute
Value
Astérix
profession
warrior
Obélix
size
extra large
32
Limitations
• Lack of standard names for links and nodes
• Combinatorial explosion of searching nodes
• Logically inadequate
– no “for all” , “ there exist”…
• Heuristically inadequate
Schema Examples
• the most frequently used instances of
schemata are
– frames [Minsky 1975]
– scripts [Schank 1977]
• frames consist of a group of slots and fillers
to define a stereotypical objects
• scripts are time-ordered sequences of
frames
34
Frame
• Suitable for related knowledge about a narrow subject with much default knowledge
• Slot: Attribute • Fillers: Value
• Example: a car frame
Slots Fillers
Manufacturer General Motors Model Chevrolet Caprice Year 1979 Transmission Automatic Engine Gasoline Tires 4 Color blue
Filler
• An assigned value
• A default value
• Rules
• Graphics
• Comments
• Debugging information
• Questions for users
• Function
• Procedual attachment
• To other frame
36
Procedural Attachment
• If-needed • If-added • If-removed
• Example: Human Property
Slots Fillers
Name property
Specialization_of A kind_of object
Types (car, boat, house)
If-added: Procedure ADD_property
Owner Default: government
If-needed: Procedure find_owner
Location (home, work, mobile)
Status (missing, poor, good)
Hierarchy
Slots Fillers
Name Car
Specialization_of A-kind-of property
Types (sedan, sports, convertible) Manufacturer (GM, Ford, Chrysler)
Location Mobile
Wheels 4
Transmission (manual, automatic) Engine (gasoline, diesel)
Slots Fillers
Name John’s car
Specialization_of Is_a car Manufacturer GM
Owner John Doe
Transmission Automatic Engine Gasoline
Status Good
38
Script
• Shopping Script:
– Roles: C (customer), S(salesperson) – Props: M(merchandise), D(dollars) – Location: L( a store)
11. C leaves L
3. C looks for a specific M 4. C looks for any interesting M 5. C asks S for help
6.
7. C finds M’
9. C leaves L 10. C buys M’
2. C begins looking around
12.goto step 2
13. C leaves L
1. C enters L
8. C fails to find M
Example
Mary went shopping for a new coat.
She found a new one she really liked.
When she got it home, she discovered that it
went perfectly with her favorite dress.
• Question:
40
Overview of Frame Structure
• two basic elements: slots and facets (fillers, values, etc.); • typically have parent and offspring slots
– used to establish a property inheritance hierarchy (e.g., specialization-of)
• descriptive slots
– contain declarative information or data (static knowledge)
• procedural attachments
– contain functions which can direct the reasoning process (dynamic knowledge)
(e.g., "activate a certain rule if a value exceeds a given level")
• data-driven, event-driven ( bottom-up reasoning) • expectation-drive or top-down reasoning
• pointers to related frames/scripts - can be used to transfer control to a more appropriate frame
41
Slots
• each slot contains one or more facets
• facets may take the following forms:
– values – default
• used if there is not other value present – range
• what kind of information can appear in the slot – if-added
• procedural attachment which specifies an action to be taken when a value in the slot is added or modified (data-driven, event-driven or bottom-up reasoning)
– if-needed
• procedural attachment which triggers a procedure which goes out to get information which the slot doesn't have (expectation-driven; top-down reasoning)
– other
42
Usage of Frames
• filling slots in frames
– can inherit the value directly – can get a default value
– these two are relatively inexpensive
– can derive information through the attached procedures (or methods) that also take advantage of current context (slot-specific heuristics)
– filling in slots also confirms that frame or script is appropriate for this particular situation
43
Restaurant Frame Example
• generic template for restaurants
– different types
– default values
• script for a typical sequence of activities at
a restaurant
44
Generic Restaurant Frame
Generic RESTAURANT Frame
Specialization-of: Business-Establishment Types:
range: (Cafeteria, Fast-Food, Seat-Yourself, Wait-To-Be-Seated) default: Seat-Yourself
if-needed: IF plastic-orange-counter THEN Fast-Food,
IF stack-of-trays THEN Cafeteria,
IF wait-for-waitress-sign or reservations-made THEN Wait-To-Be-Seated, OTHERWISE Seat-Yourself.
Location:
range: an ADDRESS if-needed: (Look at the MENU) Name:
if-needed: (Look at the MENU) Food-Style:
range: (Burgers, Chinese, American, Seafood, French) default: American
if-added: (Update Alternatives of Restaurant) Times-of-Operation:
range: a Time-of-Day
default: open evenings except Mondays Payment-Form:
range: (Cash, CreditCard, Check, Washing-Dishes-Script) Event-Sequence:
default: Eat-at-Restaurant Script Alternatives:
range: all restaurants with same Foodstyle
if-needed: (Find all Restaurants with the same Foodstyle)
45
Restaurant Script
EAT-AT-RESTAURANT Script
Props: (Restaurant, Money, Food, Menu, Tables, Chairs) Roles: (Hungry-Persons, Wait-Persons, Chef-Persons) Point-of-View: Hungry-Persons
Time-of-Occurrence: (Times-of-Operation of Restaurant) Place-of-Occurrence: (Location of Restaurant)
Event-Sequence:
first: Enter-Restaurant Script
then: if (Wait-To-Be-Seated-Sign or Reservations)
then Get-Maitre-d's-Attention Script
then: Please-Be-Seated Script then: Order-Food-Script
then: Eat-Food-Script unless (Long-Wait) when Exit-Restaurant-Angry Script then: if (Food-Quality was better than Palatable)
then Compliments-To-The-Chef Script
then: Pay-For-It-Script
46
Frame Advantages
• fairly intuitive for many applications
– similar to human knowledge organization
– suitable for causal knowledge
– easier to understand than logic or rules
Frame Problems
• it is tempting to use frames as definitions of
concepts
– not appropriate because there may be valid instances of a concept that do not fit the stereotype
– exceptions can be used to overcome this
• can get very messy
• inheritance
– not all properties of a class stereotype should be propagated to subclasses
– alteration of slots can have unintended consequences in subclasses
48
Propositional
Logic
• Proposition:
• A sentence whose truth value can be
determined.
• e.g. it is raining
• Compound statement
• Tautology
– A compound statement that is always true
• e.g. P p
• Contradiction
– A compound statement that is always false
• e.g. P p
• Contingent statement
– Neither tautology nor contradiction
• e.g. P
~
∨
~
∧
50
First-Order Predicate Logic
• The basis of logic programming languages
e.g. Prolog
• Addition: Variable
•
For all
•
There exist
e.g. (x is a triangle x is a ploygon)
( x
∀
)
∃
Fuzzy Logic
• Statement + Membership
• Membership: [0,1]
• Example:
John is tall, m=0.7
52 • 2-6:
• Tautologies: a compound statement that is always true, whether its individual are true or false.
• Contradiction: a compound statement which is always false.
• Contingent: neither a taulogies nor a contradiction. <a> If I pass the course and make an ‘A’
Then I pass the course or I make an ‘A’. <sol>
LET: I pass the course ==>P I make an ‘A’ ====>A Truth table:
Always true: Tautologies
P A 0 0 0 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 1 A P ∧ P∨ A (P∧ A)→(p∨ A)
<b>
If I pass the course then I make an ‘A’ AND
I pass this course and I do not make an ‘A’ Truth table:
Always false: Contradiction
P A ~A P-->A 0 0 1 1 0 0 0 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 0
A
P ~
∧
(P−−> A)∧(P∧~ A)54
<c>
Truth Table:
Always true: Tautologies
) ( ) ~ ( ) (A∧ B −− > C∧ C − − > A−− > B A B C A -->B 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 1 0 0 0 1 1 1 0 1 1 0 0 1 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1 1 1 B A ~∧ C∧ ~C (A∧~ B)−−> (C∧ ~C) (A∧~ B)−−>(C∧~C)−−(A−−> B) ~
<d>
Truth Table:
Always false: Contradiction
A B C A-- >B 0 0 0 1 0 0 0 0 0 0 1 1 1 0 1 0 0 1 0 1 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 1 0 0 C B∨ ~ A ~∧ C (A∧~ B)−−> (C∧ ~C) (A∧~ B)−−>(C∧~C)−−(A−−> B)
56
<e>
A- ->~B
Truth Table:
Neither tautologies nor
Contradiction = =>A -- >~B
Contingent: ≒
~
(
A
∧
B
)
A B A-->~B 0 0 1 0 1 1 1 0 1 1 1 0Representation, Reasoning and
Logic
• two parts to knowledge representation
language:
– syntax
• describes the possible configurations that can constitute sentences
– semantics
• determines the facts in the world to which the sentences refer
58
Reasoning
• process of constructing new configurations
(sentences) from old ones
– proper reasoning ensures that the new
configurations represent facts that actually
follow from the facts that the old configurations
represent
– this relationship is called entailment and can be
expressed as
KB |= alpha
• knowledge base KB entails the sentence alpha
59
Inference Methods
• an inference procedure can do one of two things:
– given a knowledge base KB, it can derive new sentences α that are (supposedly) entailed by KB
KB |- α ==> KB |= α
– given a knowledge base KB and another sentence alpha, it can report whether or not alpha is entailed by KB
KB ∧ α ==> KB |= α
• an inference procedure that generates only entailed sentences is called sound or truth-preserving
• the record of operation of a sound inference procedure is called a proof
• an inference procedure is complete if it can find a proof for any sentence that is entailed
60
KR Languages and Programming
Languages
• how is a knowledge representation language
different from a programming language (e.g. Java,
C++)?
– programming languages can be used to express facts and states
• what about "there is a pit in [2,2] or [3,1] (but we
don't know for sure)" or "there is a wumpus in
some square"
• programming languages are not expressive enough
for situations with incomplete information
– we only know some possibilities which exist
61
KR Languages and Natural
Language
• how is a knowledge representation language different from natural language
– e.g. English, Spanish, German, …
• natural languages are expressive, but have evolved to meet the needs of communication, rather than representation
• the meaning of a sentence depends on the sentence itself and on the context in which the sentence was spoken
– e.g. “Look!”
• sharing of knowledge is done without explicit representation of the knowledge itself
62
Good Knowledge Representation
Languages
• combines the best of natural and formal languages:
– expressive – concise
– unambiguous
– independent of context
• what you say today will still be interpretable tomorrow
– efficient
• the knowledge can be represented in a format that is suitable for computers
• practical inference procedures exist for the chosen format
– effective
• there is an inference procedure which can act on it to make new sentences