knowledge representation knowledge aquisition analysis representation coding representation...
Post on 19-Dec-2015
266 views
TRANSCRIPT
Knowledge Representation
Knowledge Aquisition
Analysis Representation
Coding Representation
Inference
Knowledge can be organised in various ways Many schemes available, and all of these can be:
o Programmed with existing languageso Contents can be used in reasoning
Knowledge Representation
Knowledge Analysis
Semantic networks
Scripts
Decision Trees
Coding Frames
Production Rules
Predicate logic
Approaches can be (very roughly) divided in terms of their most common usage
Logic Representation
There are two basic forms of computational logic:
PropositionalNot v. useful for AIPropositions – either TRUE or FALSEUses logic operators & symbolsProvides insight into higher representation techniques e.g.
PredicateUseful for AIAn extension of propositional logicEnhances representation by allowing use of variables & functionse.g. Colour (Ball, Red)Likes (John, Mary)Likes & Colour are predicates; Ball, Red, John Mary are constants.Can also use variables:e.g. Likes(X,Y)
Logic Symbols
Symbol Alternatives
AND n
OR u
NOT IMPLIES EQUIVALENT
x Existential quantifier, this reads ‘there exists an x..’, i.e. the value of variable x is at least 1
x Universal quantifier, this reads: ‘for all values of x…’
Example Representations
father (jeff, kim) jeff is the father of kim
father (jeff, alan) jeff is the father of alan
father (jeff, x) jeff is the father of x
x:father(jeff,x) jeff is the father to at least one person
Logic Representation
Can express rules that apply universally using
e.g. xy: father(x,y) mother (x,y) parent (x,y)
This reads:‘For all values of x and y, if x is the father of y, or x is the mother of y, then x is the parent of y’
Now look at this logic sentence:xyz:parent (x,y) parent (x,z) sibling (y,z)
What does it read as?
Logic Representation
Given the following:xy: father(x,y) mother(x,y) parent (x,y)father (jeff, kim)father(jeff, alan)
We can derive:parent (jeff, kim)parent (jeff, alan)
Facts and rules like these are easily represented in PROLOGThis is an AI language, and its name comes from PROgramming in LOGic.
Canary Bird
Wings
Fly
Is-a
hastravels
This could be expanded by adding more objects &/or properties, e.g.A similar objectA more specific objectA more general object
Semantic Networks
Made up of nodes and linksShow inheritance
Semantic Networks
Note how the ‘WALK’ node for penguin illustrates the use of EXCEPTION HANDLING
over-rides problems caused by inheritance
Writing a semantic network as a PROLOG database
ako (chair, furniture)ako (chair, seat)isa (your_chair), chair)isa (you, person)made_of (your_chair, wood)colour (wood, brown)belongs_to (your_chair, you)
Restaurant scriptTrack: Fast food restaurantRoles:
Customer (C)Server (S)
Props: CounterTrayFoodMoneyNapkinsSalt/Pepper/Ketchup/Straws
Entry Conditions: Customer is hungryCustomer has money
Scene 1: EntryCustomer (C) parks carC enters restaurantC waits in line at counterC reads menu on wall & makes decision about what to order
Scene 2: OrderC gives order to server (S)S fills order by putting food on trayC pays S
Scene 3: EatingC gets napkins, straws, salt, etc.C takes tray to un-occupied tableC eats food quickly
Scene 3a (option): Take-outC takes food and exits
Scene 4: ExitC cleans up tableC discards rubbishC leaves restaurantC drives away
Results:C no longer hungryC has less moneyC is happy *C is unhappy *C is too full *C has upset stomach *
* Options
SCRIPTS (Schank and Abelson, 1977)Similar to frames. Describes a sequence of events rather than an object. (A stereotyped sequence in a particular context)
Example:
Important components of scripts:
Entry condition: generally must be satisfied before events in a script can occur
Result: generally true after events in scripts have occurred
Props: slots representing objects involved in events in the script
Roles: slots representing people involved in events in a script
Track: specific variation of general context represented by the script
Scenes: actual sequence of events that occur
Primarily applied to higher thinking skills/ language processing.
Various programs developed.
Schank applies it to story telling (1991) and later in educational software (1995).
Related to Case Based Reasoning (also Schank)
What kind of holiday is required?
activitybeach
What type of climate?
What type of climate?
averagehot
cool
hot
average
Preferred region?
asiaeurope
america
floridaS. france,
Spain
Malaysia,India
Etc. Etc.
Useful way of modelling knowledge for expert systems.
A simple (& incomplete) example might beas shown left
Decision Trees
Decision Trees are a good way to design rules for rule based systems
Production Rules
•IF Premise THEN conclusion•These are used in the Leonardo expert system shell
•The rules in this example are in the decision frame rule set. •They all have ‘decision’ in the consequent part of the rule (i.e. after the word THEN)
Production Rules
Shows main rule set
Production Rules
This is the outcome frame, showing the rule that gives a value to outcome in the ruleset.
Production Rules
This shows part of the decision frame (some of the slots, and the first rule in the ruleset).
Frames
These are data structures that include all knowledge about a particular object.
They have a hierarchical structure They can be seen as an application of Object-Oriented
programming to AI, though in fact, frames came first. Contain a large chunk of information about a particular
object Describes object in great detail Usually represent stereotyped knowledge based on well
known experiences etc. Contain SLOTS and FACETS
Mammal:Subclass: AnimalHas-part: head
Nellie:Instance: elephantLikes: apples
SLOT – attributes that describe the object
FACET – describes knowledge/ procedures about the attribute. So Facets can be values, default values, ranges of values etc.
Elephant:Subclass: mammalColour: greySize: large
Frames
Mammal:Subclass: animalWarm-blooded: yes* furry: yes
Elephant:Subclass: mammalHas-trunk: yes*colour: grey*size: largefurry: no
Clyde:Instance: elephantColour: pinkOwner: Fred
Nellie:Instance: ElephantSize: small
Elephant frames with defaults:
Automobile Frame
Class of: TransportationName of Manufacturer: AudiOrigin of manufacturer: GermanyModel: 5000 TurboType of car: SedanWeight: 1500KgWheelbase: 265cmNumber of doors: 4 (default)Transmission: 3-speed automaticNumber of wheels: 4 (default)Engine: (Reference Engine frame)
Type: In-line, overhead camNumber of cylinders: 5
Acceleration (procedural attachment)0-60: 10.4 secondsQuarter mile: 17.1 seconds, 85mphGas mileage: 22 mpg average (procedural attachment)
Engine frame
Cylinder bore: 7.975 cmCylinder stroke: 8.49 cmCompression ratio: 7.8 to 1Fuel system: injection with turbochargerHorsepower: 140 hpTorque: 160 ft/LB
Example of Frames
Advantages & disadvantages of different
knowledge representations Scheme Advantages Disadvantages
Production Rules
Simple syntax, easy to understand, simple interpreter, highly modular, flexible – easy to add to or modify, suited to many domains
Hard to follow hierarchies, inefficient for large systems, not all knowledge can be expressed as rules, poor at representing structured descriptive knowledge
Semantic Networks
Easy to follow hierarchy, easy to trace associations, flexible, good analysis tool especially for frames development.
Meaning attached to nodes might be ambiguous, exception handling is difficult, difficult to program, no facility for procedural knowledge, inferencing limited to inheritance of properties
Frames Expressive power, easy to set up new slots, easy to create specialised procedures, easy to include defaults & detect missing values, good organisation of knowledge, Object based so facilitates re-usability
Can become complex as instances of objects depart from prototypes, problems when new situuations are encountered, hard to express negation, hard to express when one thing OR another is true.
Formal logic Facts asserted independently of use, enables/supports precision & completeness, powerful way to represent and reason, can handle negation etc.
Separation of representation & processing, inefficient with large data sets, slow with large knowledge bases, difficult to represent uncertainty, poor psychological model
Inference
TWO common inference mechanisms used in Expert Systems for reasoning:
Forward Chaining (Data-Driven Reasoning)
Backward Chaining (Goal-Directed Reasoning)
Forward Chaining
Starts with known facts and uses these to reason forward with the given rules.
Test each rule and fire every rule whose antecedent (IF part) can be shown to be true.
This generates more data.
The rules are tested again.
System performs this process iteratively until no more rules are fired.
Backward Chaining
Assume hypothetical solution that we try to prove using the rules. Look for rules that have our goal in the consequent (THEN part).
Search antecedents to see what we need to know to fire that rule.
If we can fire the rule, then the goal is proved. Rarely happens at this point though.
We put aside (stack) the rule, and set up a sub-goal for proving the antecedent of the rule.
Search knowledge base for rules that help us prove the sub-goal.
Once again we find the antecedents and repeat the process stacking rules until we have none left to help us prove the current sub-goal.
Would now query the user for a value. Having got this, we can evaluate the last rule, un-stack it and proceed to the next, etc.
Inference
Forward chaining assumes we know all the facts, and just works with that. Never prompts the user.
Backward chaining assumes no data, and only asks for any that we need to prove the direct line of reasoning. Backward chaining can occur in either breadth first or depth first modes (see lecture on search techniques).
Rule 1 If cat is happyAnd jenny is relaxedThen goal is achieved
Rule 2 If bowl is fullThen cat is happy
Rule 3 If telly is onThen jenny is relaxed
Rule 4 If cat is happyThen purring is happening
Forward Chaining: given that bowl is full, and telly is on as initial facts
Cat is happyBowl is fullJenny is relaxedTelly is onPurring is happeningGoal is achieved
Pass 1 Rule 2 fires, cat is instantiated as happyRule 3 fires, jenny is instantiated as relaxedRule 4 fires, purring is instantiated as happening
Pass 2 Rule 1 fires, goal is instantiated as achieved
At the end of the process we know that:
Backward chaining: Seek Goal
ACTIONS GOALS and INSTANTIATIONS
Try Rule 1Stack rule 1
Need value for cat
Try Rule 2No rule, query user
Need value for bowlBowl instantiated to full by user input
Rule 2 Fires Cat instantiated to happy
Un-stack Rule 1Stack rule 1
Need value for jenny
Try Rule 3No rule, query user
Need value for tellyTelly instantiated to on by user
input
Rule 3 fires Jenny instantiated to relaxed
Un-stack rule 1
Rule 1 fires Goal instantiated to achieved
Cat is happyBowl is fullJenny is relaxedTelly is onGoal is achieved
We now know:
Purring was not instantiated because it’s not in our line of reasoning.
Inference
Leonardo uses depth first backward chaining with opportunistic forward chaining.
So any initial data it has (e.g. in fixed value slots in the frames) is used for forward chaining, when no further rules fire backward chaining takes over.
When an object is instantiated either through rule or user query, forward chaining is triggered again, then backward chaining resumes, etc.
Summary
Propositional LogicSemantic NetworksScriptsTreesRulesFramesForward and Backward Chaining