Knowledge and reasoning using frames - Artificial Intelligence

Frames are a form of knowledge representation proposed by Marvin Minsky. A frame is a data structure that stores prototypical information relating to a specific concept. Frames consists of ‘slots’ which can have ‘values’ that are either explicitly declared when the frame is declared, or they are inherited from a parent frame. This form of knowledge representation is the one most reminiscent of Gärdenfors conceptual spaces model, with slots being analogous to quality dimensions.

There are two types of frame:a class frame;and an individual or instance frame. Inheritance is usually specified using the ‘ako’ slot (this stands for ‘a kind of’). For example, in the zoo animals classification problem,a cheetah is a kind of mammal, and a mammal is a kind of animal. As a further example, the frames for the Sailing boat classification problem are shown in Table below. The table shows the eight sailing boat frames in separate columns,with slot names and values shown in the rows. For this particular problem, the knowledge is relatively regular,with only a few table cells with missing values.Normally, missing values are the norm when the frames are listed in tabular form because there is no requirement that each frame should have the same slots, because frames represent different concepts with different properties, and can inherit information from different parent frames.

The event map representation for this knowledge is shown in Figure. For clarity purposes,the figure shows the event map for just the first four frames for the Sailing boat problem – the Jib-headed cutter (top left), the Gaff-headed sloop (bottom left), the Jib-headed ketch (top right) and the Gaffheaded ketch (bottom right). Each frame is depicted as a separate path, starting from the event state labelled by the frame’s name (for example, name = “jib-headed-cutter” on the top left), then proceeding to a state that declares what kind of frame the path represents (this state is always labelled as ako = “[boat]” as all the frames are boat frames in this example). The path then proceeds through the states that represent each frame’s specific slots and values.

Table : The frames for the Sailing boat classification problem shown in tabular form.

frames for the Sailing boat classification problem

Rather than declaring the frames separately from the rules based knowledge, the Knowledge Representation model instead uses the approach of converting the rule-based knowledge into frame format. This is in order to illustrate the correspondence between the two approaches when the propositions in the rules are specified using attribute value pairs. This also allows the different methods to be visualised using event maps. The code for doing this is shown in NetLogo Code below.

NetLogo Code : How the rules-base is converted into a frames-base.

to convert-rules-to-frames-base [problem]
;; Converts the rules base to a frames base
let this-rule nobody
let this-frame nobody
let attribute ""
let value ""
ask frames [ die ] ; kill off any previous frames
foreach sort rules
[ ; for each rule in the rules base
set this-rule ?
foreach [consequents] of this-rule
set attribute (first ?)
set value (last ?)
set this-frame find-frame? attribute value
if (this-frame = nobody)
[ ; frame does not exist with that name and type
create-frames 1
hide-turtle ; make invisible
set this-frame self
set name value
set ako-list (list attribute)
set slots-table table:make
foreach [antecedents] of this-rule
ask this-frame
set attribute (first ?)
set value (last ?)
ifelse (member? attribute [input-attributes] of problem)
[ table:put slots-table attribute value ]
[ set ako-list
(lput value ako-list) ] ; add value to ako-list
to-report find-frame? [this-ako this-name]
;; reports the frame that has slot value "ako" = ako and "name" = name.
;; reports nobody otherwise
report one-of frames with
[member? this-ako ako-list and name = this-name]

The conversion procedure first kills off any existing frames, then processes each of the rules in the rule-base in turn. For the consequents of each rule, it checks that a frame with the same name and ako slot values do not already exist by calling the find-frame? reporter. If it does not exist,it will create a new frame, otherwise it will use the one that was found. Then it will insert slots and their values into the slots-table for the frame if the proposition attribute is an input attribute, otherwise it adds the proposition’s value to the ako-list for the frame. The event map is created from these frames using the add-events procedure as shown in NetLogo Code.

NetLogo Code : How the frames are used to create an event map.

to-report slots-events [table]
;; returns the list of events for the slots table
let events []
let keys []
let value ""
set keys table:keys table
foreach keys
set value table:get table ?
set events lput (list ? value) events
report events
to setup-frames
;; setups a network of states from the frames
init-problem ; initialise the selected problem
let events []
convert-rules-to-frames-base selected-problem
foreach sort frames
set events slots-events [slots-table] of ?
set events fput (fput "ako" (list [ako-list] of ?)) events
set events fput (list "name" [name] of ?) events
add-events events white white white
repeat 5 [ change-layout ]

This code defines the setup-frames procedure that calls the convert-rules-to-frames base procedure defined above,then for each of the newly created frames, it generates a list of events for each of the frame’s slots in its slots table (by calling the slots-events reporter), and then adds two further events at the beginning of the events list, one for the ako-list and another for the name of the frame, before calling the add-events procedure.

There are two main types of reasoning with frames–reasoning via inheritance, and reasoning via matching. The former fills in missing slot values for frames if there is a slot value specified for a parent frame.For example, for the Sailing boat problem,a parent ‘boat’ frame could specify that the number of sails by default for boats is two. Recall that the purpose of a frame is to represent a prototypical concept, so in specifying that the boat frame has two sails,then this is defining that the prototypical boat will have two sails.

There are of course always exceptions to the rule,and therefore a default parent frame value can easily be overridden in a child frame by inserting a specific value.Cars, for example, mostly have four wheels, but some cars have three wheels such as the Reliant Robin manufactured in England in the 1970s, and recent hybrid and electric cars that adopt the three wheel solution for aerodynamic and performance reasons. So a parent ‘car’ frame might set the slot value for ‘number of wheels’ to 4, but set the value to 3 instead for the ‘Reliant Robin car’ frame, for example.

The second form of reasoning for frames based on matching involves searching the frames-base for a frame whose slots and values match the current known facts. This has been implemented in the Knowledge Representation model. Figure below is a screenshot that provides an intermediate stage of the reasoning process to show how it proceeds.

The event map of the knowledge in the first four frames for the Sailing boats problem showing the progress of the frame-matching reasoning process.

event map of the knowledge in the first four frames for the Sailing boats problem showing the progress of the frame-matching reasoning process.

In the screenshot, the paths that have been followed are depicted by thicker white links. The first question asked, due to the Jib-headed cutter being the first frame matched,is “How many masts are there?” because the slot “number of masts” was being matched. The user replied with “two”, which resulted with both the Jib-headed cutter frame and the next frame, the Gaff-headed sloop, failing to match. This is shown by the walker agents stopping just short of the end of the two paths shown on the left of the screenshot. The reasoning process then tried to match the next frame in the frames-base–the Jib-headed ketch frame. The screenshot shows the stage after the question “What is the main mast position?” had been answered with “forward of the short mast”, and the user is about to answer the next question “What is the short mast position?” displayed in the centre of the screenshot.

The code that performs the frame matching process is defined by the go-frames-reasoning procedure within the Knowledge Representation model in NetLogo. Rather than reproduce the code here, the reader can examine the code directly in NetLogo by selecting the Procedures button. The code consists of a reporter,match-frame?, that returns true if a frame matches the current facts. The match-frame? reporter first creates a new walker agent, and moves it along the beginning of the frame’s path in the event map through the name and ako states. Then it processes each of the names in the frame’s ako-list to make sure each of the parent frames match by recursively calling match-frame?.

This will also mean that the grandparent frames (and great-grandparent frames and so on) will also need to be matched before the frame itself can match.Once all these parent frameshave been matched,the reporter then extracts the list of slot names from the frame ’s slots-table, and then for each of the slots,extracts their values and using similar code to that used in the rule-based reasoning listed above in Section, will try to see if a fact with the slot name and value already exists in the facts-base.If not, it will ask the user for input if the slot is an input attribute, otherwise it will return false (the frame has not matched).

The go-frames-reasoning procedure calls the match-frame? reporter for each of the frames that have the goal attribute in their ako-list which is set when the frames are created–for example, for the Sailing boat frames-base the goal attribute is set to boat, and for the zoo animals frames-base the goal attribute is set to animal, and therefore only those frames are matched for the problem. There are many variations to the frame-based method of knowledge representation. An extension to the basic slot-value type of representation is to allow the slots to have ‘facets’ to provide extended knowledge about the attribute being described by the slot.Facets can be used for controlling user queries and guiding the reasoning process, for example detailing how the slot should be matched.Methods (called ‘demons’) can also be associated with attributes as facets that provide the frame-based system a mechanism for expressing procedural knowledge.

These methods perform actions that are triggered under certain conditions.For example, two common types of methods are WHEN CHANGED and WHEN NEEDED, which are triggered when a slot’s value is changed or when it is accessed.

Many expert and intelligent systems today are hybrid systems that combine two or more technologies; for example, many systems use both frames and rules for representing knowledge and for reasoning. A term often used to describe these hybrid systems is ‘soft computing’ which deals with systems that are capable of reasoning with uncertainties and dynamic multiple-agent environments. Negnevitsky provides several examples of hybrid intelligent systems that combine various technologies, not just the symbolic-based technologies such as rules and frames, but also the sub-symbolic technologies such as neural networks and evolutionary computing.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Artificial Intelligence Topics