4.8 Adding new Concepts

Finally we look how to implement a new concept for existing objects and fit this in the method selection. Three examples that will be made more explicit below would be groups for which a ``length'' of elements (as a word in certain generators) is defined, groups that can be decomposed as a semidirect product and M-groups.

In each case we have two possibilities for the declaration. We can either declare it as a property or as a category. Both are eventually filter and in this way indistinguishable for the method selection. The distinction is rather conceptual and mainly reflects whether we want existing objects to be part of our new concept or not.

Property:
Properties also are attributes: If a property value is not known for an object, GAP tries to find a method to compute the property value. If no suitable method is found, an error is raised.

Category:
An object is in a category if it has been created in it. Testing the category for an object simply returns this value. Existing objects cannot enter a new category later in life. This means that in most cases one has to write own code to create objects in a new category.

If we want to implement a completely new concept so that new operations are defined only for the new objects -- for example bialgebras for which a second scalar multiplication is defined -- usually a category is chosen.

Technically, the behaviour of the category IsXYZ, declared as subcategory of IsABC is therefore exactly the same as if we would declare IsXYZ to be a property for IsABC and install the following method:
InstallMethod(IsXYZ,"return false if not known",[IsABC],ReturnFalse);
(The words category also has a well-defined mathematical meaning, but this does not need to concern us at this point. The set of objects which is defined to be a (GAP)-category does not need to be a category in the mathematical sense, vice versa not every mathematical category is declared as a (GAP) category.)
Eventually the coice between category and property often becomes a matter of taste or style.

Sometimes there is even a third possiblity (if you have GAP 3 experience this might reflect most closely ``an object whose operations record is XYOps''): We might want to indicate this new concept simply by the fact that certain attributes are set. In this case we could simply use the respective attribute tester(s).

The examples given below each give a short argument why the respective solution was chosen, but one could argue as well for other choices.

[Top] [Previous] [Up] [Next] [Index]

GAP 4 manual
February 2000