Science
Copyright © 2024 Jiri Kriz, www.nosco.ch

13    Frames, Inheritance, Demons

Solutions

13.1    Frames

Write a simple shell for the processing of frames according to the lecture script. The frames will be represented in Prolog as

frame_id( slot, facet, value).

such that they can be accessed easily.

The shell should support the following operations:

get_value( Frame, Slot, Value)
put_value( Frame, Slot, Value)
create_instance( Frame, Instance_Frame).

The predicate create_instance( Frame, Instance_Frame) creates the frame Instance_Frame with the is_a relationship to Frame.

The following facets should be supported:

value, if_needed, if_added.

The corresponding demons are triggered automatically when the functions (Prolog predicates) get_value und put_value are called. The demon funkcions (Prolog predicates) are defined as:

demon( Frame, Slot, Value) :- .... .

Solution 13.1

13.2    Application: Hierarchy of Graphical Objects

Apply the shell from Example 13.1 to create a hierarchy of graphical objects:

Graphical object (slots: position (x,y)):

It should be possible to create instances of these classes with as few inputs as possible.

You can add further slots and extend the hierarchy.

Solution 13.2