Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1X13 [33X[0;0YTypes of Objects[133X[101X23[33X[0;0YEvery [5XGAP[105X object has a [13Xtype[113X. The type of an object is the information which4is used to decide whether an operation is admissible or possible with that5object as an argument, and if so, how it is to be performed (see6Chapter [14X78[114X).[133X78[33X[0;0YFor example, the types determine whether two objects can be multiplied and9what function is called to compute the product. Analogously, the type of an10object determines whether and how the size of the object can be computed. It11is sometimes useful in discussing the type system, to identify types with12the set of objects that have this type. Partial types can then also be13regarded as sets, such that any type is the intersection of its parts.[133X1415[33X[0;0YThe type of an object consists of two main parts, which describe different16aspects of the object.[133X1718[33X[0;0YThe [13Xfamily[113X determines the relation of the object to other objects. For19example, all permutations form a family. Another family consists of all20collections of permutations, this family contains the set of permutation21groups as a subset. A third family consists of all rational functions with22coefficients in a certain family.[133X2324[33X[0;0YThe other part of a type is a collection of [13Xfilters[113X (actually stored as a25bit-list indicating, from the complete set of possible filters, which are26included in this particular type). These filters are all treated equally by27the method selection, but, from the viewpoint of their creation and use,28they can be divided (with a small number of unimportant exceptions) into29categories, representations, attribute testers and properties. Each of these30is described in more detail below.[133X3132[33X[0;0YThis chapter does not describe how types and their constituent parts can be33created. Information about this topic can be found in Chapter [14X79[114X.[133X3435[33X[0;0Y[13XNote:[113X Detailed understanding of the type system is not required to use [5XGAP[105X.36It can be helpful, however, to understand how things work and why [5XGAP[105X37behaves the way it does.[133X3839[33X[0;0YA discussion of the type system can be found in [BL98].[133X404142[1X13.1 [33X[0;0YFamilies[133X[101X4344[33X[0;0YThe family of an object determines its relationship to other objects.[133X4546[33X[0;0YMore precisely, the families form a partition of all [5XGAP[105X objects such that47the following two conditions hold: objects that are equal w.r.t. [10X=[110X lie in48the same family; and the family of the result of an operation depends only49on the families of its operands.[133X5051[33X[0;0YThe first condition means that a family can be regarded as a set of elements52instead of a set of objects. Note that this does not hold for categories and53representations (see below), two objects that are equal w.r.t. [10X=[110X need not54lie in the same categories and representations. For example, a sparsely55represented matrix can be equal to a densely represented matrix. Similarly,56each domain is equal w.r.t. [10X=[110X to the sorted list of its elements, but a57domain is not a list, and a list is not a domain.[133X5859[1X13.1-1 FamilyObj[101X6061[33X[1;0Y[29X[2XFamilyObj[102X( [3Xobj[103X ) [32X function[133X6263[33X[0;0Yreturns the family of the object [3Xobj[103X.[133X6465[33X[0;0YThe family of the object [3Xobj[103X is itself an object, its family is66[10XFamilyOfFamilies[110X.[133X6768[33X[0;0YIt should be emphasized that families may be created when they are needed.69For example, the family of elements of a finitely presented group is created70only after the presentation has been constructed. Thus families are the71dynamic part of the type system, that is, the part that is not fixed after72the initialisation of [5XGAP[105X.[133X7374[33X[0;0YFamilies can be parametrized. For example, the elements of each finitely75presented group form a family of their own. Here the family of elements and76the finitely presented group coincide when viewed as sets. Note that77elements in different finitely presented groups lie in different families.78This distinction allows [5XGAP[105X to forbid multiplications of elements in79different finitely presented groups.[133X8081[33X[0;0YAs a special case, families can be parametrized by other families. An82important example is the family of [13Xcollections[113X that can be formed for each83family. A collection consists of objects that lie in the same family, it is84either a nonempty dense list of objects from the same family or a domain.[133X8586[33X[0;0YNote that every domain is a collection, that is, it is not possible to87construct domains whose elements lie in different families. For example, a88polynomial ring over the rationals cannot contain the integer [10X0[110X because the89family that contains the integers does not contain polynomials. So one has90to distinguish the integer zero from each zero polynomial.[133X9192[33X[0;0YLet us look at this example from a different viewpoint. A polynomial ring93and its coefficients ring lie in different families, hence the coefficients94ring cannot be embedded [21Xnaturally[121X into the polynomial ring in the sense that95it is a subset. But it is possible to allow, e.g., the multiplication of an96integer and a polynomial over the integers. The relation between the97arguments, namely that one is a coefficient and the other a polynomial, can98be detected from the relation of their families. Moreover, this analysis is99easier than in a situation where the rationals would lie in one family100together with all polynomials over the rationals, because then the relation101of families would not distinguish the multiplication of two polynomials, the102multiplication of two coefficients, and the multiplication of a coefficient103with a polynomial. So the wish to describe relations between elements can be104taken as a motivation for the introduction of families.[133X105106107[1X13.2 [33X[0;0YFilters[133X[101X108109[33X[0;0YA [13Xfilter[113X is a special unary [5XGAP[105X function that returns either [9Xtrue[109X or [9Xfalse[109X,110depending on whether or not the argument lies in the set defined by the111filter. Filters are used to express different aspects of information about a112[5XGAP[105X object, which are described below (see [14X13.3[114X, [14X13.4[114X, [14X13.5[114X, [14X13.6[114X, [14X13.7[114X,113[14X13.8[114X).[133X114115[33X[0;0YPresently any filter in [5XGAP[105X is implemented as a function which corresponds116to a set of positions in the bitlist which forms part of the type of each117[5XGAP[105X object, and returns [9Xtrue[109X if and only if the bitlist of the type of the118argument has the value [9Xtrue[109X at all of these positions.[133X119120[33X[0;0YThe intersection (or meet) of two filters [3Xfilt1[103X, [3Xfilt2[103X is again a filter, it121can be formed as[133X122123[33X[0;0Y[3Xfilt1[103X [9Xand[109X [3Xfilt2[103X[133X124125[33X[0;0YSee [14X20.4[114X for more details.[133X126127[33X[0;0YFor example, [10XIsList and IsEmpty[110X is a filter that returns [9Xtrue[109X if its128argument is an empty list, and [9Xfalse[109X otherwise. The filter [2XIsGroup[102X ([14X39.2-7[114X)129is defined as the intersection of the category [2XIsMagmaWithInverses[102X ([14X35.1-4[114X)130and the property [2XIsAssociative[102X ([14X35.4-7[114X).[133X131132[33X[0;0YA filter that is not the meet of other filters is called a [13Xsimple filter[113X.133For example, each attribute tester (see [14X13.6[114X) is a simple filter. Each134simple filter corresponds to a position in the bitlist currently used as135part of the data structure representing a type.[133X136137[33X[0;0YEvery filter has a [13Xrank[113X, which is used to define a ranking of the methods138installed for an operation, see Section [14X78.2[114X. The rank of a filter can be139accessed with [2XRankFilter[102X ([14X13.2-1[114X).[133X140141[1X13.2-1 RankFilter[101X142143[33X[1;0Y[29X[2XRankFilter[102X( [3Xfilt[103X ) [32X function[133X144145[33X[0;0YFor simple filters, an [13Xincremental rank[113X is defined when the filter is146created, see the sections about the creation of filters: [14X79.1[114X, [14X79.2[114X, [14X79.3[114X,147[14X79.4[114X. For an arbitrary filter, its rank is given by the sum of the148incremental ranks of the [13Xinvolved[113X simple filters; in addition to the implied149filters, these are also the required filters of attributes (again see the150sections about the creation of filters). In other words, for the purpose of151computing the rank and [13Xonly[113X for this purpose, attribute testers are treated152as if they would imply the requirements of their attributes.[133X153154[1X13.2-2 NamesFilter[101X155156[33X[1;0Y[29X[2XNamesFilter[102X( [3Xfilt[103X ) [32X function[133X157158[33X[0;0Y[2XNamesFilter[102X returns a list of names of the [13Ximplied[113X simple filters of the159filter [3Xfilt[103X, these are all those simple filters [10Ximp[110X such that every object160in [3Xfilt[103X also lies in [10Ximp[110X. For implications between filters, see161[2XShowImpliedFilters[102X ([14X13.2-3[114X) as well as sections [14X78.7[114X, [14X79.1[114X, [14X79.2[114X, [14X79.3[114X.[133X162163[1X13.2-3 ShowImpliedFilters[101X164165[33X[1;0Y[29X[2XShowImpliedFilters[102X( [3Xfilter[103X ) [32X function[133X166167[33X[0;0YDisplays information about the filters that may be implied by [3Xfilter[103X. They168are given by their names. [10XShowImpliedFilters[110X first displays the names of all169filters that are unconditionally implied by [3Xfilter[103X. It then displays170implications that require further filters to be present (indicating by [10X+[110X the171required further filters). The function displays only first-level172implications, implications that follow in turn are not displayed (though [5XGAP[105X173will do these).[133X174175[4X[32X Example [32X[104X176[4X[25Xgap>[125X [27XShowImpliedFilters(IsMatrix);[127X[104X177[4X[28XImplies:[128X[104X178[4X[28X IsGeneralizedRowVector[128X[104X179[4X[28X IsNearAdditiveElementWithInverse[128X[104X180[4X[28X IsAdditiveElement[128X[104X181[4X[28X IsMultiplicativeElement[128X[104X182[4X[28X[128X[104X183[4X[28X[128X[104X184[4X[28XMay imply with:[128X[104X185[4X[28X+IsGF2MatrixRep[128X[104X186[4X[28X IsOrdinaryMatrix[128X[104X187[4X[28X[128X[104X188[4X[28X+CategoryCollections(CategoryCollections(IsAdditivelyCommutativeElement))[128X[104X189[4X[28X IsAdditivelyCommutativeElement[128X[104X190[4X[28X[128X[104X191[4X[28X+IsInternalRep[128X[104X192[4X[28X IsOrdinaryMatrix[128X[104X193[4X[28X[128X[104X194[4X[32X[104X195196197[1X13.3 [33X[0;0YCategories[133X[101X198199[33X[0;0YThe [13Xcategories[113X of an object are filters (see [14X13.2[114X) that determine what200operations an object admits. For example, all integers form a category, all201rationals form a category, and all rational functions form a category. An202object which claims to lie in a certain category is accepting the203requirement that it should have methods for certain operations (and perhaps204that their behaviour should satisfy certain axioms). For example, an object205lying in the category [2XIsList[102X ([14X21.1-1[114X) must have methods for [2XLength[102X206([14X21.17-5[114X), [2XIsBound\[\][102X ([14X21.2-1[114X) and the list element access operation [2X\[\][102X207([14X21.2-1[114X).[133X208209[33X[0;0YAn object can lie in several categories. For example, a row vector lies in210the categories [2XIsList[102X ([14X21.1-1[114X) and [2XIsVector[102X ([14X31.14-14[114X); each list lies in211the category [2XIsCopyable[102X ([14X12.6-1[114X), and depending on whether or not it is212mutable, it may lie in the category [2XIsMutable[102X ([14X12.6-2[114X). Every domain lies in213the category [2XIsDomain[102X ([14X31.9-1[114X).[133X214215[33X[0;0YOf course some categories of a mutable object may change when the object is216changed. For example, after assigning values to positions of a mutable217non-dense list, this list may become part of the category [2XIsDenseList[102X218([14X21.1-2[114X).[133X219220[33X[0;0YHowever, if an object is immutable then the set of categories it lies in is221fixed.[133X222223[33X[0;0YAll categories in the library are created during initialization, in224particular they are not created dynamically at runtime.[133X225226[33X[0;0YThe following list gives an overview of important categories of arithmetic227objects. Indented categories are to be understood as subcategories of the228non indented category listed above it.[133X229230[4X[32X Example [32X[104X231[4X[28X IsObject[128X[104X232[4X[28X IsExtLElement[128X[104X233[4X[28X IsExtRElement[128X[104X234[4X[28X IsMultiplicativeElement[128X[104X235[4X[28X IsMultiplicativeElementWithOne[128X[104X236[4X[28X IsMultiplicativeElementWithInverse[128X[104X237[4X[28X IsExtAElement[128X[104X238[4X[28X IsAdditiveElement[128X[104X239[4X[28X IsAdditiveElementWithZero[128X[104X240[4X[28X IsAdditiveElementWithInverse[128X[104X241[4X[32X[104X242243[33X[0;0YEvery object lies in the category [2XIsObject[102X ([14X12.1-1[114X).[133X244245[33X[0;0YThe categories [2XIsExtLElement[102X ([14X31.14-8[114X) and [2XIsExtRElement[102X ([14X31.14-9[114X) contain246objects that can be multiplied with other objects via [10X*[110X from the left and247from the right, respectively. These categories are required for the operands248of the operation [10X*[110X.[133X249250[33X[0;0YThe category [2XIsMultiplicativeElement[102X ([14X31.14-10[114X) contains objects that can be251multiplied from the left and from the right with objects from the same252family. [2XIsMultiplicativeElementWithOne[102X ([14X31.14-11[114X) contains objects [10Xobj[110X for253which a multiplicatively neutral element can be obtained by taking the [22X0[122X-th254power [10Xobj^0[110X. [2XIsMultiplicativeElementWithInverse[102X ([14X31.14-13[114X) contains objects255[10Xobj[110X for which a multiplicative inverse can be obtained by forming [10Xobj^-1[110X.[133X256257[33X[0;0YLikewise, the categories [2XIsExtAElement[102X ([14X31.14-1[114X), [2XIsAdditiveElement[102X258([14X31.14-3[114X), [2XIsAdditiveElementWithZero[102X ([14X31.14-5[114X) and259[2XIsAdditiveElementWithInverse[102X ([14X31.14-7[114X) contain objects that can be added via260[10X+[110X to other objects, objects that can be added to objects of the same family,261objects for which an additively neutral element can be obtained by262multiplication with zero, and objects for which an additive inverse can be263obtained by multiplication with [10X-1[110X.[133X264265[33X[0;0YSo a vector lies in [2XIsExtLElement[102X ([14X31.14-8[114X), [2XIsExtRElement[102X ([14X31.14-9[114X) and266[2XIsAdditiveElementWithInverse[102X ([14X31.14-7[114X). A ring element must additionally lie267in [2XIsMultiplicativeElement[102X ([14X31.14-10[114X).[133X268269[33X[0;0YAs stated above it is not guaranteed by the categories of objects whether270the result of an operation with these objects as arguments is defined. For271example, the category [2XIsMatrix[102X ([14X24.2-1[114X) is a subcategory of272[2XIsMultiplicativeElementWithInverse[102X ([14X31.14-13[114X). Clearly not every matrix has273a multiplicative inverse. But the category [2XIsMatrix[102X ([14X24.2-1[114X) makes each274matrix an admissible argument of the operation [2XInverse[102X ([14X31.10-8[114X), which may275sometimes return [9Xfail[109X. Likewise, two matrices can be multiplied only if they276are of appropriate shapes.[133X277278[33X[0;0YAnalogous to the categories of arithmetic elements, there are categories of279domains of these elements.[133X280281[4X[32X Example [32X[104X282[4X[28X IsObject[128X[104X283[4X[28X IsDomain[128X[104X284[4X[28X IsMagma[128X[104X285[4X[28X IsMagmaWithOne[128X[104X286[4X[28X IsMagmaWithInversesIfNonzero[128X[104X287[4X[28X IsMagmaWithInverses[128X[104X288[4X[28X IsAdditiveMagma[128X[104X289[4X[28X IsAdditiveMagmaWithZero[128X[104X290[4X[28X IsAdditiveMagmaWithInverses[128X[104X291[4X[28X IsExtLSet[128X[104X292[4X[28X IsExtRSet[128X[104X293[4X[32X[104X294295[33X[0;0YOf course [2XIsDomain[102X ([14X31.9-1[114X) is a subcategory of [2XIsObject[102X ([14X12.1-1[114X). A domain296that is closed under multiplication [10X*[110X is called a magma and it lies in the297category [2XIsMagma[102X ([14X35.1-1[114X). If a magma is closed under taking the identity,298it lies in [2XIsMagmaWithOne[102X ([14X35.1-2[114X), and if it is also closed under taking299inverses, it lies in [2XIsMagmaWithInverses[102X ([14X35.1-4[114X). The category300[2XIsMagmaWithInversesIfNonzero[102X ([14X35.1-3[114X) denotes closure under taking inverses301only for nonzero elements, every division ring lies in this category.[133X302303[33X[0;0YNote that every set of categories constitutes its own notion of generation,304for example a group may be generated as a magma with inverses by some305elements, but to generate it as a magma with one it may be necessary to take306the union of these generators and their inverses.[133X307308[1X13.3-1 CategoriesOfObject[101X309310[33X[1;0Y[29X[2XCategoriesOfObject[102X( [3Xobject[103X ) [32X operation[133X311312[33X[0;0Yreturns a list of the names of the categories in which [3Xobject[103X lies.[133X313314[4X[32X Example [32X[104X315[4X[25Xgap>[125X [27Xg:=Group((1,2),(1,2,3));;[127X[104X316[4X[25Xgap>[125X [27XCategoriesOfObject(g);[127X[104X317[4X[28X[ "IsListOrCollection", "IsCollection", "IsExtLElement",[128X[104X318[4X[28X "CategoryCollections(IsExtLElement)", "IsExtRElement",[128X[104X319[4X[28X "CategoryCollections(IsExtRElement)",[128X[104X320[4X[28X "CategoryCollections(IsMultiplicativeElement)",[128X[104X321[4X[28X "CategoryCollections(IsMultiplicativeElementWithOne)",[128X[104X322[4X[28X "CategoryCollections(IsMultiplicativeElementWithInverse)",[128X[104X323[4X[28X "CategoryCollections(IsAssociativeElement)",[128X[104X324[4X[28X "CategoryCollections(IsFiniteOrderElement)", "IsGeneralizedDomain",[128X[104X325[4X[28X "CategoryCollections(IsPerm)", "IsMagma", "IsMagmaWithOne",[128X[104X326[4X[28X "IsMagmaWithInversesIfNonzero", "IsMagmaWithInverses" ][128X[104X327[4X[32X[104X328329330[1X13.4 [33X[0;0YRepresentation[133X[101X331332[33X[0;0YThe [13Xrepresentation[113X of an object is a set of filters (see [14X13.2[114X) that333determines how an object is actually represented. For example, a matrix or a334polynomial can be stored sparsely or densely; all dense polynomials form a335representation. An object which claims to lie in a certain representation is336accepting the requirement that certain fields in the data structure be337present and have specified meanings.[133X338339[33X[0;0Y[5XGAP[105X distinguishes four essentially different ways to represent objects.340First there are the representations [10XIsInternalRep[110X for internal objects such341as integers and permutations, and [10XIsDataObjectRep[110X for other objects that are342created and whose data are accessible only by kernel functions. The data343structures underlying such objects cannot be manipulated at the [5XGAP[105X level.[133X344345[33X[0;0YAll other objects are either in the representation [10XIsComponentObjectRep[110X or346in the representation [10XIsPositionalObjectRep[110X, see [14X79.10[114X and [14X79.11[114X.[133X347348[33X[0;0YAn object can belong to several representations in the sense that it lies in349several subrepresentations of [10XIsComponentObjectRep[110X or of350[10XIsPositionalObjectRep[110X. The representations to which an object belongs should351form a chain and either two representations are disjoint or one is contained352in the other. So the subrepresentations of [10XIsComponentObjectRep[110X and353[10XIsPositionalObjectRep[110X each form trees. In the language of Object Oriented354Programming, we support only single inheritance for representations.[133X355356[33X[0;0YThese trees are typically rather shallow, since for one representation to be357contained in another implies that all the components of the data structure358implied by the containing representation, are present in, and have the same359meaning in, the smaller representation (whose data structure presumably360contains some additional components).[133X361362[33X[0;0YObjects may change their representation, for example a mutable list of363characters can be converted into a string.[133X364365[33X[0;0YAll representations in the library are created during initialization, in366particular they are not created dynamically at runtime.[133X367368[33X[0;0YExamples of subrepresentations of [10XIsPositionalObjectRep[110X are [10XIsModulusRep[110X,369which is used for residue classes in the ring of integers, and370[10XIsDenseCoeffVectorRep[110X, which is used for elements of algebras that are371defined by structure constants.[133X372373[33X[0;0YAn important subrepresentation of [10XIsComponentObjectRep[110X is374[10XIsAttributeStoringRep[110X, which is used for many domains and some other375objects. It provides automatic storing of all attribute values (see below).[133X376377[1X13.4-1 RepresentationsOfObject[101X378379[33X[1;0Y[29X[2XRepresentationsOfObject[102X( [3Xobject[103X ) [32X operation[133X380381[33X[0;0Yreturns a list of the names of the representations [3Xobject[103X has.[133X382383[4X[32X Example [32X[104X384[4X[25Xgap>[125X [27Xg:=Group((1,2),(1,2,3));;[127X[104X385[4X[25Xgap>[125X [27XRepresentationsOfObject(g);[127X[104X386[4X[28X[ "IsComponentObjectRep", "IsAttributeStoringRep" ][128X[104X387[4X[32X[104X388389390[1X13.5 [33X[0;0YAttributes[133X[101X391392[33X[0;0YThe attributes of an object describe knowledge about it.[133X393394[33X[0;0YAn attribute is a unary operation without side-effects.[133X395396[33X[0;0YAn object may store values of its attributes once they have been computed,397and claim that it knows these values. Note that [21Xstore[121X and [21Xknow[121X have to be398understood in the sense that it is very cheap to get such a value when the399attribute is called again.[133X400401[33X[0;0YThe stored value of an attribute is in general immutable (see [14X12.6[114X), except402if the attribute had been specially constructed as [21Xmutable attribute[121X.[133X403404[33X[0;0YIt depends on the representation of an object (see [14X13.4[114X) which attribute405values it stores. An object in the representation [10XIsAttributeStoringRep[110X406stores [13Xall[113X attribute values once they are computed. Moreover, for an object407in this representation, subsequent calls to an attribute will return the408[13Xsame[113X object; this is achieved via a special method for each attribute setter409that stores the attribute value in an object in [10XIsAttributeStoringRep[110X, and a410special method for the attribute itself that fetches the stored attribute411value. (These methods are called the [21Xsystem setter[121X and the [21Xsystem getter[121X of412the attribute, respectively.)[133X413414[33X[0;0YNote also that it is impossible to get rid of a stored attribute value415because the system may have drawn conclusions from the old attribute value,416and just removing the value might leave the data structures in an417inconsistent state. If necessary, a new object can be constructed.[133X418419[33X[0;0YSeveral attributes have methods for more than one argument. For example420[2XIsTransitive[102X ([14X41.10-1[114X) is an attribute for a [22XG[122X-set that can also be called421for the two arguments, being a group [22XG[122X and its action domain. If attributes422are called with more than one argument then the return value is not stored423in any of the arguments.[133X424425[33X[0;0YProperties are a special form of attributes that have the value [9Xtrue[109X or426[9Xfalse[109X, see section [14X13.7[114X.[133X427428[33X[0;0YExamples of attributes for multiplicative elements are [2XInverse[102X ([14X31.10-8[114X),429[2XOne[102X ([14X31.10-2[114X), and [2XOrder[102X ([14X31.10-10[114X). [2XSize[102X ([14X30.4-6[114X) is an attribute for430domains, [2XCentre[102X ([14X35.4-5[114X) is an attribute for magmas, and [2XDerivedSubgroup[102X431([14X39.12-3[114X) is an attribute for groups.[133X432433[1X13.5-1 KnownAttributesOfObject[101X434435[33X[1;0Y[29X[2XKnownAttributesOfObject[102X( [3Xobject[103X ) [32X operation[133X436437[33X[0;0Yreturns a list of the names of the attributes whose values are known for438[3Xobject[103X.[133X439440[4X[32X Example [32X[104X441[4X[25Xgap>[125X [27Xg:=Group((1,2),(1,2,3));;Size(g);;[127X[104X442[4X[25Xgap>[125X [27XKnownAttributesOfObject(g);[127X[104X443[4X[28X[ "Size", "OneImmutable", "NrMovedPoints", "MovedPoints", [128X[104X444[4X[28X "GeneratorsOfMagmaWithInverses", "MultiplicativeNeutralElement", [128X[104X445[4X[28X "HomePcgs", "Pcgs", "GeneralizedPcgs", "StabChainMutable", [128X[104X446[4X[28X "StabChainOptions" ][128X[104X447[4X[32X[104X448449450[1X13.6 [33X[0;0YSetter and Tester for Attributes[133X[101X451452[33X[0;0YFor every attribute, the [13Xattribute setter[113X and the [13Xattribute tester[113X are453defined.[133X454455[33X[0;0YTo check whether an object belongs to an attribute [3Xattr[103X, the tester of the456attribute is used, see [2XTester[102X ([14X13.6-1[114X). To store a value for the attribute457[3Xattr[103X in an object, the setter of the attribute is used, see [2XSetter[102X ([14X13.6-2[114X).[133X458459[1X13.6-1 Tester[101X460461[33X[1;0Y[29X[2XTester[102X( [3Xattr[103X ) [32X function[133X462463[33X[0;0YFor an attribute [3Xattr[103X, [10XTester([3Xattr[103X[10X)[110X is a filter (see [14X13.2[114X) that returns [9Xtrue[109X464or [9Xfalse[109X, depending on whether or not the value of [3Xattr[103X for the object is465known. For example, [10XTester( Size )( [3Xobj[103X[10X )[110X is [9Xtrue[109X if the size of the object466[3Xobj[103X is known.[133X467468[1X13.6-2 Setter[101X469470[33X[1;0Y[29X[2XSetter[102X( [3Xattr[103X ) [32X function[133X471472[33X[0;0YFor an attribute [3Xattr[103X, [10XSetter([3Xattr[103X[10X)[110X is called automatically when the473attribute value has been computed for the first time. One can also call the474setter explicitly, for example, [10XSetter( Size )( [3Xobj[103X[10X, [3Xval[103X[10X )[110X sets [3Xval[103X as size475of the object [3Xobj[103X if the size was not yet known.[133X476477[33X[0;0YFor each attribute [3Xattr[103X that is declared with [2XDeclareAttribute[102X ([14X79.18-3[114X)478resp. [2XDeclareProperty[102X ([14X79.18-4[114X) (see [14X79.18[114X), tester and setter are479automatically made accessible by the names [10XHas[3Xattr[103X[10X[110X and [10XSet[3Xattr[103X[10X[110X,480respectively. For example, the tester for [2XSize[102X ([14X30.4-6[114X) is called [10XHasSize[110X,481and the setter is called [10XSetSize[110X.[133X482483[4X[32X Example [32X[104X484[4X[25Xgap>[125X [27Xg:=Group((1,2,3,4),(1,2));;Size(g);[127X[104X485[4X[28X24[128X[104X486[4X[25Xgap>[125X [27XHasSize(g);[127X[104X487[4X[28Xtrue[128X[104X488[4X[25Xgap>[125X [27XSetSize(g,99);[127X[104X489[4X[25Xgap>[125X [27XSize(g);[127X[104X490[4X[28X24[128X[104X491[4X[32X[104X492493[33X[0;0YFor two properties [3Xprop1[103X and [3Xprop2[103X, the intersection [10X[3Xprop1[103X[10X and [3Xprop2[103X[10X[110X494(see [14X13.2[114X) is again a property for which a setter and a tester exist.495Setting the value of this intersection to [9Xtrue[109X for a [5XGAP[105X object means to set496the values of [3Xprop1[103X and [3Xprop2[103X to [9Xtrue[109X for this object.[133X497498[4X[32X Example [32X[104X499[4X[25Xgap>[125X [27Xprop:= IsFinite and IsCommutative;[127X[104X500[4X[28X<Property "<<and-filter>>">[128X[104X501[4X[25Xgap>[125X [27Xg:= Group( (1,2,3), (4,5) );;[127X[104X502[4X[25Xgap>[125X [27XTester( prop )( g );[127X[104X503[4X[28Xfalse[128X[104X504[4X[25Xgap>[125X [27XSetter( prop )( g, true );[127X[104X505[4X[25Xgap>[125X [27XTester( prop )( g ); prop( g );[127X[104X506[4X[28Xtrue[128X[104X507[4X[28Xtrue[128X[104X508[4X[32X[104X509510[33X[0;0YIt is [13Xnot allowed[113X to set the value of such an intersection to [9Xfalse[109X for an511object.[133X512513[4X[32X Example [32X[104X514[4X[25Xgap>[125X [27XSetter( prop )( Rationals, false );[127X[104X515[4X[28XYou cannot set an "and-filter" except to true[128X[104X516[4X[28Xnot in any function[128X[104X517[4X[28XEntering break read-eval-print loop ...[128X[104X518[4X[28Xyou can 'quit;' to quit to outer loop, or[128X[104X519[4X[28Xyou can type 'return true;' to set all components true[128X[104X520[4X[28X(but you might really want to reset just one component) to continue[128X[104X521[4X[26Xbrk>[126X [27X[127X[104X522[4X[32X[104X523524[1X13.6-3 AttributeValueNotSet[101X525526[33X[1;0Y[29X[2XAttributeValueNotSet[102X( [3Xattr[103X, [3Xobj[103X ) [32X function[133X527528[33X[0;0YIf the value of the attribute [3Xattr[103X is already stored for [3Xobj[103X,529[10XAttributeValueNotSet[110X simply returns this value. Otherwise the value of [10X[3Xattr[103X[10X(530[3Xobj[103X[10X )[110X is computed and returned [13Xwithout storing it[113X in [3Xobj[103X. This can be useful531when [21Xlarge[121X attribute values (such as element lists) are needed only once and532shall not be stored in the object.[133X533534[4X[32X Example [32X[104X535[4X[25Xgap>[125X [27XHasAsSSortedList(g);[127X[104X536[4X[28Xfalse[128X[104X537[4X[25Xgap>[125X [27XAttributeValueNotSet(AsSSortedList,g);[127X[104X538[4X[28X[ (), (4,5), (1,2,3), (1,2,3)(4,5), (1,3,2), (1,3,2)(4,5) ][128X[104X539[4X[25Xgap>[125X [27XHasAsSSortedList(g);[127X[104X540[4X[28Xfalse[128X[104X541[4X[32X[104X542543[33X[0;0YThe normal behaviour of attributes (when called with just one argument) is544that once a method has been selected and executed, and has returned a value545the setter of the attribute is called, to (possibly) store the computed546value. In special circumstances, this behaviour can be altered dynamically547on an attribute-by-attribute basis, using the functions548[10XDisableAttributeValueStoring[110X and [10XEnableAttributeValueStoring[110X.[133X549550[33X[0;0YIn general, the code in the library assumes, for efficiency, but not for551correctness, that attribute values [13Xwill[113X be stored (in suitable objects), so552disabling storing may cause substantial computations to be repeated.[133X553554[1X13.6-4 InfoAttributes[101X555556[33X[1;0Y[29X[2XInfoAttributes[102X[32X info class[133X557558[33X[0;0YThis info class (together with [2XInfoWarning[102X ([14X7.4-7[114X) is used for messages559about attribute storing being disabled (at level 2) or enabled (level 3). It560may be used in the future for other messages concerning changes to attribute561behaviour.[133X562563[1X13.6-5 DisableAttributeValueStoring[101X564565[33X[1;0Y[29X[2XDisableAttributeValueStoring[102X( [3Xattr[103X ) [32X function[133X566567[33X[0;0Ydisables the usual call of [10XSetter( [3Xattr[103X[10X )[110X when a method for [3Xattr[103X returns a568value. In consequence the values will never be stored. Note that [3Xattr[103X must569be an attribute and [13Xnot[113X a property.[133X570571[1X13.6-6 EnableAttributeValueStoring[101X572573[33X[1;0Y[29X[2XEnableAttributeValueStoring[102X( [3Xattr[103X ) [32X function[133X574575[33X[0;0Yenables the usual call of [10XSetter( [3Xattr[103X[10X )[110X when a method for [3Xattr[103X returns a576value. In consequence the values may be stored. This will usually have no577effect unless [10XDisableAttributeValueStoring[110X has previously been used for578[3Xattr[103X. Note that [3Xattr[103X must be an attribute and [13Xnot[113X a property.[133X579580[4X[32X Example [32X[104X581[4X[25Xgap>[125X [27Xg := Group((1,2,3,4,5),(1,2,3));[127X[104X582[4X[28XGroup([ (1,2,3,4,5), (1,2,3) ])[128X[104X583[4X[25Xgap>[125X [27XKnownAttributesOfObject(g);[127X[104X584[4X[28X[ "LargestMovedPoint", "GeneratorsOfMagmaWithInverses", [128X[104X585[4X[28X "MultiplicativeNeutralElement" ][128X[104X586[4X[25Xgap>[125X [27XSetInfoLevel(InfoAttributes,3);[127X[104X587[4X[25Xgap>[125X [27XDisableAttributeValueStoring(Size);[127X[104X588[4X[28X#I Disabling value storing for Size[128X[104X589[4X[25Xgap>[125X [27XSize(g);[127X[104X590[4X[28X60[128X[104X591[4X[25Xgap>[125X [27XKnownAttributesOfObject(g);[127X[104X592[4X[28X[ "OneImmutable", "LargestMovedPoint", "NrMovedPoints", [128X[104X593[4X[28X "MovedPoints", "GeneratorsOfMagmaWithInverses", [128X[104X594[4X[28X "MultiplicativeNeutralElement", "StabChainMutable", [128X[104X595[4X[28X "StabChainOptions" ][128X[104X596[4X[25Xgap>[125X [27XSize(g);[127X[104X597[4X[28X60[128X[104X598[4X[25Xgap>[125X [27XEnableAttributeValueStoring(Size);[127X[104X599[4X[28X#I Enabling value storing for Size[128X[104X600[4X[25Xgap>[125X [27XSize(g);[127X[104X601[4X[28X60[128X[104X602[4X[25Xgap>[125X [27XKnownAttributesOfObject(g);[127X[104X603[4X[28X[ "Size", "OneImmutable", "LargestMovedPoint", "NrMovedPoints", [128X[104X604[4X[28X "MovedPoints", "GeneratorsOfMagmaWithInverses", [128X[104X605[4X[28X "MultiplicativeNeutralElement", "StabChainMutable", [128X[104X606[4X[28X "StabChainOptions" ][128X[104X607[4X[32X[104X608609610[1X13.7 [33X[0;0YProperties[133X[101X611612[33X[0;0YThe properties of an object are those of its attributes (see [14X13.5[114X) whose613values can only be [9Xtrue[109X or [9Xfalse[109X.[133X614615[33X[0;0YThe main difference between attributes and properties is that a property616defines two sets of objects, namely the usual set of all objects for which617the value is known, and the set of all objects for which the value is known618to be [9Xtrue[109X.[133X619620[33X[0;0Y(Note that it makes no sense to consider a third set, namely the set of621objects for which the value of a property is [9Xtrue[109X whether or not it is622known, since there may be objects for which the containment in this set623cannot be decided.)[133X624625[33X[0;0YFor a property [3Xprop[103X, the containment of an object [3Xobj[103X in the first set is626checked again by applying [10XTester( [3Xprop[103X[10X )[110X to [3Xobj[103X, and [3Xobj[103X lies in the second627set if and only if [10XTester( [3Xprop[103X[10X )( [3Xobj[103X[10X ) and [3Xprop[103X[10X( [3Xobj[103X[10X )[110X is [9Xtrue[109X.[133X628629[33X[0;0YIf a property value is known for an immutable object then this value is also630stored, as part of the type of the object. To some extent, property values631of mutable objects also can be stored, for example a mutable list all of632whose entries are immutable can store whether it is strictly sorted. When633the object is mutated (for example by list assignment) the type may need to634be adjusted.[133X635636[33X[0;0YImportant properties for domains are [2XIsAssociative[102X ([14X35.4-7[114X), [2XIsCommutative[102X637([14X35.4-9[114X), [2XIsAnticommutative[102X ([14X56.4-6[114X), [2XIsLDistributive[102X ([14X56.4-3[114X) and638[2XIsRDistributive[102X ([14X56.4-4[114X), which mean that the multiplication of elements in639the domain satisfies [22X( a * b ) * c = a * ( b * c )[122X, [22Xa * b = b * a[122X, [22Xa * b = -640( b * a )[122X, [22Xa * ( b + c ) = a * b + a * c[122X, and [22X( a + b ) * c = a * c + b * c[122X,641respectively, for all [22Xa[122X, [22Xb[122X, [22Xc[122X in the domain.[133X642643[1X13.7-1 KnownPropertiesOfObject[101X644645[33X[1;0Y[29X[2XKnownPropertiesOfObject[102X( [3Xobject[103X ) [32X operation[133X646647[33X[0;0Yreturns a list of the names of the properties whose values are known for648[3Xobject[103X.[133X649650[1X13.7-2 KnownTruePropertiesOfObject[101X651652[33X[1;0Y[29X[2XKnownTruePropertiesOfObject[102X( [3Xobject[103X ) [32X operation[133X653654[33X[0;0Yreturns a list of the names of the properties known to be [9Xtrue[109X for [3Xobject[103X.[133X655656[4X[32X Example [32X[104X657[4X[25Xgap>[125X [27Xg:=Group((1,2),(1,2,3));;[127X[104X658[4X[25Xgap>[125X [27XKnownPropertiesOfObject(g);[127X[104X659[4X[28X[ "IsFinite", "CanEasilyCompareElements", "CanEasilySortElements", [128X[104X660[4X[28X "IsDuplicateFree", "IsGeneratorsOfMagmaWithInverses", [128X[104X661[4X[28X "IsAssociative", "IsGeneratorsOfSemigroup", "IsSimpleSemigroup", [128X[104X662[4X[28X "IsRegularSemigroup", "IsInverseSemigroup", [128X[104X663[4X[28X "IsCompletelyRegularSemigroup", "IsCompletelySimpleSemigroup", [128X[104X664[4X[28X "IsGroupAsSemigroup", "IsMonoidAsSemigroup", "IsOrthodoxSemigroup", [128X[104X665[4X[28X "IsFinitelyGeneratedGroup", "IsSubsetLocallyFiniteGroup", [128X[104X666[4X[28X "KnowsHowToDecompose", "IsNilpotentByFinite" ][128X[104X667[4X[25Xgap>[125X [27XSize(g);[127X[104X668[4X[28X6[128X[104X669[4X[25Xgap>[125X [27XKnownPropertiesOfObject(g);[127X[104X670[4X[28X[ "IsEmpty", "IsTrivial", "IsNonTrivial", "IsFinite", [128X[104X671[4X[28X "CanEasilyCompareElements", "CanEasilySortElements", [128X[104X672[4X[28X "IsDuplicateFree", "IsGeneratorsOfMagmaWithInverses", [128X[104X673[4X[28X "IsAssociative", "IsGeneratorsOfSemigroup", "IsSimpleSemigroup", [128X[104X674[4X[28X "IsRegularSemigroup", "IsInverseSemigroup", [128X[104X675[4X[28X "IsCompletelyRegularSemigroup", "IsCompletelySimpleSemigroup", [128X[104X676[4X[28X "IsGroupAsSemigroup", "IsMonoidAsSemigroup", "IsOrthodoxSemigroup", [128X[104X677[4X[28X "IsFinitelyGeneratedGroup", "IsSubsetLocallyFiniteGroup", [128X[104X678[4X[28X "KnowsHowToDecompose", "IsPerfectGroup", "IsSolvableGroup", [128X[104X679[4X[28X "IsPolycyclicGroup", "IsNilpotentByFinite", "IsTorsionFree", [128X[104X680[4X[28X "IsFreeAbelian" ][128X[104X681[4X[25Xgap>[125X [27XKnownTruePropertiesOfObject(g);[127X[104X682[4X[28X[ "IsNonTrivial", "IsFinite", "CanEasilyCompareElements", [128X[104X683[4X[28X "CanEasilySortElements", "IsDuplicateFree", [128X[104X684[4X[28X "IsGeneratorsOfMagmaWithInverses", "IsAssociative", [128X[104X685[4X[28X "IsGeneratorsOfSemigroup", "IsSimpleSemigroup", [128X[104X686[4X[28X "IsRegularSemigroup", "IsInverseSemigroup", [128X[104X687[4X[28X "IsCompletelyRegularSemigroup", "IsCompletelySimpleSemigroup", [128X[104X688[4X[28X "IsGroupAsSemigroup", "IsMonoidAsSemigroup", "IsOrthodoxSemigroup", [128X[104X689[4X[28X "IsFinitelyGeneratedGroup", "IsSubsetLocallyFiniteGroup", [128X[104X690[4X[28X "KnowsHowToDecompose", "IsSolvableGroup", "IsPolycyclicGroup", [128X[104X691[4X[28X "IsNilpotentByFinite" ][128X[104X692[4X[32X[104X693694695[1X13.8 [33X[0;0YOther Filters[133X[101X696697[33X[0;0YThere are situations where one wants to express a kind of knowledge that is698based on some heuristic.[133X699700[33X[0;0YFor example, the filters (see [14X13.2[114X) [2XCanEasilyTestMembership[102X ([14X39.25-1[114X) and701[2XCanEasilyComputePcgs[102X ([14X45.2-3[114X) are defined in the [5XGAP[105X library. Note that such702filters do not correspond to a mathematical concept, contrary to properties703(see [14X13.7[114X). Also it need not be defined what [21Xeasily[121X means for an arbitrary704[5XGAP[105X object, and in this case one cannot compute the value for an arbitrary705[5XGAP[105X object. In order to access this kind of knowledge as a part of the type706of an object, [5XGAP[105X provides filters for which the value is [9Xfalse[109X by default,707and it is changed to [9Xtrue[109X in certain situations, either explicitly (for the708given object) or via a logical implication (see [14X78.7[114X) from other filters.[133X709710[33X[0;0YFor example, a [9Xtrue[109X value of [2XCanEasilyComputePcgs[102X ([14X45.2-3[114X) for a group means711that certain methods are applicable that use a pcgs (see [14X45.1[114X) for the712group. There are logical implications to set the filter value to [9Xtrue[109X for713permutation groups that are known to be solvable, and for groups that have714already a (sufficiently nice) pcgs stored. In the case one has a solvable715matrix group and wants to enable methods that use a pcgs, one can set the716[2XCanEasilyComputePcgs[102X ([14X45.2-3[114X) value to [9Xtrue[109X for this particular group.[133X717718[33X[0;0YA filter [3Xfilt[103X of the kind described here is different from the other filters719introduced in the previous sections. In particular, [3Xfilt[103X is not a category720(see [14X13.3[114X) or a property (see [14X13.7[114X) because its value may change for a given721object, and [3Xfilt[103X is not a representation (see [14X13.4[114X) because it has nothing722to do with the way an object is made up from some data. [3Xfilt[103X is similar to723an attribute tester (see [14X13.6[114X), the only difference is that [3Xfilt[103X does not724refer to an attribute value; note that [3Xfilt[103X is also used in the same way as725an attribute tester; namely, the [9Xtrue[109X value may be required for certain726methods to be applicable.[133X727728729[1X13.9 [33X[0;0YTypes[133X[101X730731[33X[0;0YWe stated above (see [14X13[114X) that, for an object [3Xobj[103X, its [13Xtype[113X is formed from732its family and its filters. There is a also a third component, used in a few733situations, namely defining data of the type.[133X734735[1X13.9-1 TypeObj[101X736737[33X[1;0Y[29X[2XTypeObj[102X( [3Xobj[103X ) [32X function[133X738739[33X[0;0Yreturns the type of the object [3Xobj[103X.[133X740741[33X[0;0YThe type of an object is itself an object.[133X742743[33X[0;0YTwo types are equal if and only if the two families are identical, the744filters are equal, and, if present, also the defining data of the types are745equal.[133X746747[1X13.9-2 DataType[101X748749[33X[1;0Y[29X[2XDataType[102X( [3Xtype[103X ) [32X function[133X750751[33X[0;0YThe last part of the type, defining data, has not been mentioned before and752seems to be of minor importance. It can be used, e.g., for cosets [22XU g[122X of a753group [22XU[122X, where the type of each coset may contain the group [22XU[122X as defining754data. As a consequence, two such cosets mod [22XU[122X and [22XV[122X can have the same type755only if [22XU = V[122X. The defining data of the type [3Xtype[103X can be accessed via756[2XDataType[102X.[133X757758759760