Lecture 4 Associative Nets & Frames 1
ASSOCIATIVE NETS AND FRAME SYSTEMS Network Representations If L is - - PowerPoint PPT Presentation
ASSOCIATIVE NETS AND FRAME SYSTEMS Network Representations If L is - - PowerPoint PPT Presentation
ASSOCIATIVE NETS AND FRAME SYSTEMS Network Representations If L is a set of labeled links and N is a set of nodes, then a network is any subset of NLN, where the order of the triples is material. Lecture 4 Associative Nets & Frames
Lecture 4 Associative Nets & Frames 2
Associationist Theories of Meaning
Associationist theories define the meaning of an
- bject in terms of a network of associations
with other objects in a mind or a knowledge base. e.g. through experience we associate the concept
- f snow with other concepts such as cold,
white, snowman, slippery and ice.
Lecture 4 Associative Nets & Frames 3
Network Representation of properties
- f snow and ice
ice hard clear
hardness temperature
soft slippery white cold snow snowman
made of texture color temperature color
Lecture 4 Associative Nets & Frames 4
Implementing Network Representation in CLIPS
CLIPS> (deftemplate net ;network representation (slot name (type SYMBOL) ) (slot color (type SYMBOL) ) (slot temperature (type SYMBOL) ) (slot texture (type SYMBOL) ) (slot hardness (type SYMBOL) ) ) CLIPS> (deffacts things ;defining two things (net (name snow) (color white) (temperature cold) (texture slippery) (hardness soft)) (net (name ice) (color clear) (texture slippery) (temperature cold) (hardness hard)))
Lecture 4 Associative Nets & Frames 5
Implementing Network Representation in CLIPS (contd.)
;Associating snow with something else which is also cold CLIPS> (defrule association (net (name snow) (temperature cold)) (net (name ?Y&~snow) (temperature cold)) => (printout t "snow reminds me of " ?Y crlf))
Lecture 4 Associative Nets & Frames 6
Implementing Network Representation in CLIPS (contd.)
CLIPS> (watch facts) CLIPS> (watch rules) CLIPS> (reset) ==> f-0 (initial-fact) ==> f-1 (net (name snow) (color white) (temperature cold) (texture slipper) (hardness soft) ==> f-2 (net (name ice) (color clear) (temperature cold) (texture slippery) (hardness hard) CLIPS> (run) FIRE 1 association: f-1, f-2 snow reminds me of ice
Lecture 4 Associative Nets & Frames 7
Semantic Network by Collins & Quillian
can has has is a FISH can is a BIRD ANIMAL Fly Wings Feathers Breathe Skin Sing Yellow CANARY can is Sing Tall OSTRICH cannot is Move has can is a is a
Lecture 4 Associative Nets & Frames 8
Human Information Storage and Response Time
1.5 1.4 1.3 1.2 1.1 1.0 0.9 Response Time (sec) A canary is a bird A canary can sing “Complexity” of sentence A canary has skin A canary can fly A canary is a canary A canary is an animal
Lecture 4 Associative Nets & Frames 9
Implementing Semantic Nets in CLIPS
CLIPS> (deftemplate species (slot node (type SYMBOL) ) (slot is-a (type SYMBOL) ) (multislot is (type SYMBOL) ) (multislot has (type SYMBOL) ) (multislot can (type SYMBOL) ) (multislot cannot (type SYMBOL) ) ) CLIPS> (deffacts biology (species (node canary) (is-a bird) (is yellow) (can fly) ) (species (node ostrich) (is tall) (cannot fly) (is-a bird) ) (species (node bird) (is-a animal) (can fly) (has wings feather) ) (species (node fish) (is-a animal) ) (species (node animal) (can breathe move) (has bones skin) ) )
Lecture 4 Associative Nets & Frames 10
Implementing Semantic Nets in CLIPS (contd.)
CLIPS> (defrule link1 (declare (salience 10)) (species (node ?X)(is-a ?Y&~nil)) => (printout t "A " ?X " is a " ?Y crlf)) CLIPS> (defrule link2 (declare (salience 5)) (species (node ?X) (is-a ?Y)) (species (node ?Y) (is-a ?Z&~nil)) => (printout t "A " ?X " is a " ?Z crlf))
Lecture 4 Associative Nets & Frames 11
Implementing Semantic Nets in CLIPS (contd.)
CLIPS> (defrule link3 (species (node ?X) (is-a ?Y)) (species (node ?Y) (is-a ?Z)) (species (node ?Z) (has $?W)) => (printout t "A " ?X " has " (implode$ ?W) crlf))
Lecture 4 Associative Nets & Frames 12
Implementing Semantic Nets in CLIPS (contd.)
CLIPS> (reset) CLIPS> (run) A fish is a animal A bird is a animal A ostrich is a bird A canary is a bird A canary is a animal A ostrich is a animal A ostrich has bones skin A canary has bones skin
Lecture 4 Associative Nets & Frames 13
Semantic Nets for Natural Language
The word “give” has the following associated roles: a donor, a recipient and an object given.
give person person thing
recipient donor
- bject
Lecture 4 Associative Nets & Frames 14
An Instance of a Semantic Net
give-1 john mary book
recipient donor
- bject
Knowledge derived from “John gave Mary a book”.
Lecture 4 Associative Nets & Frames 15
Natural Language Grammar Rules
S NP VP
; S=Sentence, NP=Noun Phrase, VP=Verb Phrase
NP Proper_Noun | Article Noun | Noun VP VP PP
; PP=Prepositional Phrase
VP Verb NP PP Prep NP Proper_Noun Sarah Noun chair | glue Article the Prep with
Lecture 4 Associative Nets & Frames 16
Natural Language Parsing
S NP VP Proper_Noun Sarah VP PP Verb NP Prep NP Article Noun fixed the chair with glue
Syntactic Analysis:
Lecture 4 Associative Nets & Frames 17
Case Frame for English Verbs
Semantic Analysis: Knowledge representation for “Sarah fixed the chair with glue”
fix past chair glue sarah time
- bject
instrument agent
Lecture 4 Associative Nets & Frames 18
CLIPS Template for Case Frame
CLIPS> (deftemplate case (slot verb (type SYMBOL) ) (slot agent (type SYMBOL)) (slot object (type SYMBOL) ) (slot time (type SYMBOL) ) (slot instrument (type SYMBOL) ) )
Lecture 4 Associative Nets & Frames 19
Structured Representations
- Organizing knowledge into a structure called
frame.
- A frame may be viewed as a data structure
used to represent well-understood stereotyped situations
- Example: birds as prototypical objects with a
general property that most birds can fly though there are exceptions.
Lecture 4 Associative Nets & Frames 20
Frame Systems
A frame system attempts to integrate
– Declarative notions about objects and events and their properties, and – Procedural notions about how to retrieve information and achieve goals.
Lecture 4 Associative Nets & Frames 21
A Frame
Name: Name-1 Attribute-1: value-1 Attribute-2: procedure-1 . . . . . Attribute-n: value-m Attribute-3: procedure-2 Slots Fillers (procedures are sometimes known as demons)
Lecture 4 Associative Nets & Frames 22
Hierarchy of Frames
- Frames are typically arranged in a hierarchy in
which “lower” frames can inherit values from “higher” frames in the hierarchy.
- Properties and procedures for “higher” frames
are more or less fixed whereas “lower” frames may be filled with more contingent information.
Lecture 4 Associative Nets & Frames 23
Links in a Frame System
- Instances − Classes
- Classes - Superclasses
Machine Computer SunA SunFire Superclass Class Instances
Lecture 4 Associative Nets & Frames 24
Inheritance System of Birds
bird superclass: vertebrate reproduction: lay_eggs covering: feathers can fly: T scavenger superclass: bird diet: (garbage carrion) sparrow superclass: songbird habitat: north america songbird superclass: bird diet: (bugs seeds) canary superclass: songbird habitat: tropical tweety instance of: canary fightless bird superclass: bird can fly: nil penguin superclass: flightless_bird habitat: south pole diet: fish
- pus
instance of: penguin
Lecture 4 Associative Nets & Frames 25
Hierarchical Representation for Geometric Figures of Land
Each node in the hierarchy consists of a structure with the following format: NAME: Number of Sides: Length of Sides: Size of Angles: Area: Price of Land:
Polygon Quadrilateral Trapezium Parallelogram Rectangle Square
Lecture 4 Associative Nets & Frames 26
Defaults and Demons
Some of the slots in “Polygon” may have the following fillers: Number of Sides: 4 (default) Area: compute_area (IF-NEEDED demon) Price=compute_price(Area) (IF-ADDED demon) Price: receives value from above when Area is added or updated.
Lecture 4 Associative Nets & Frames 27
Implementing Frames in CLIPS
CLIPS> (defclass polygon (is-a USER) ) CLIPS> (defclass quadrilateral (is-a polygon) ) CLIPS> (defclass trapezium (is-a quadrilateral) ) CLIPS> (defclass parallelogram (is-a trapezium) ) CLIPS> (defclass rectangle (is-a trapezium) ) CLIPS> (defclass square (is-a rectangle) )
Lecture 4 Associative Nets & Frames 28
Abstract and Concrete Classes
CLIPS> (defclass polygon (is-a USER) (role abstract) (slot no_of_sides (default 4) ) ) CLIPS> (defclass quadrilateral (is-a polygon) (role concrete) ) Concrete classes can generate instances while abstract classes will not.
Lecture 4 Associative Nets & Frames 29
Defining a demon
CLIPS> (defmessage-handler polygon sides ( ) ?self: no-of-sides) CLIPS> (definstances geometry (square-one of square) ) CLIPS> (send [square-one] sides) 4
Lecture 4 Associative Nets & Frames 30
Multiple Inheritance in Heterarchical Representation
Polygon Regular Polygon Triangle Isosceles Triangle Equilateral Triangle Quadrilateral Rectangle Square There is no ambiguity if “Square” inherits different information from “Regular Polygon” and “Rectangle”. The same applies to “Equilateral Triangle”
Lecture 4 Associative Nets & Frames 31
Conflicting Defaults among Frames
Person Quaker Republican Republican Quaker
(defclass person (is-a USER) ) (defclass quaker (is-a person) ) (defclass republican (is-a person) ) (defclass republican-quaker (is-a republican quaker) (role concrete) )
Lecture 4 Associative Nets & Frames 32