You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CAP/doc/AddFunctions.autodoc
+64-51Lines changed: 64 additions & 51 deletions
Original file line number
Diff line number
Diff line change
@@ -4,18 +4,21 @@ This section describes the overall structure of Add-functions and the functions
4
4
5
5
@Section Functions Installed by Add
6
6
7
-
Add functions (up to some exceptions) have the following syntax
7
+
Add functions have the following syntax:
8
8
9
+
@BeginCode AddSomeFunc
9
10
DeclareOperation( "AddSomeFunc",
10
11
[ IsCapCategory, IsList, IsInt ] );
12
+
@EndCode
11
13
12
-
The first argument is the category to which some function (e.g. KernelObject)
14
+
@InsertCode AddSomeFunc
15
+
16
+
The first argument is the category to which some function (e.g. `KernelObject`)
13
17
is added, the second is a list containing pairs of functions and additional
14
-
filters for the arguments, (e.g. if one argument is a morphism, an additional filter could be IsMomomorphism).
15
-
The third is a weight which will then be the weight for SomeFunc. This is described later.
18
+
filters for the arguments, (e.g. if one argument is a morphism, an additional filter could be `IsMomomorphism`).
19
+
The third is an optional weight which will then be the weight for `SomeFunc` (default value: 100). This is described later.
16
20
If only one function is to be installed, the list can be replaced by the function.
17
-
Via InstallMethod, CAP installs the given function(s) as methods for the install name of SomeFunc,
18
-
as listed in the MethodRecord. If no install name is given, the name SomeFunc is used.
21
+
CAP installs the given function(s) as methods for `SomeFunc` (resp. `SomeFuncOp` if `SomeFunc` is not an operation).
19
22
20
23
All installed methods follow the following steps, described below:
21
24
* Redirect function
@@ -25,90 +28,85 @@ All installed methods follow the following steps, described below:
25
28
* Postfunction
26
29
* Addfunction
27
30
28
-
Every other part, except from function, does only depend on the name SomeFunc. We now explain the steps in detail.
31
+
Every other part, except from function, does only depend on the name `SomeFunc`. We now explain the steps in detail.
29
32
30
33
* Redirect function: The redirect is used to redirect the computation from the given functions to some other symbol.
31
34
If there is for example a with given method for some universal property, and the universal object is already computed,
32
35
the redirect function might detect such a thing, calls the with given operation with the universal object as additional
33
36
argument and then returns the value. In general, the redirect can be an arbitrary function. It is called with the same
34
-
arguments as the operation SomeFunc itself and can return an array containing [ true, something ], which will cause
35
-
the installed method to simply return the object something, or [ false ]. If the output is false, the computation will
36
-
continue with the step Prefunction. Additionally, for every category and every name like SomeFunc, there is a boolean,
37
-
stored in the categorys redirects component under the name of SomeFunc, which, when it is false, will prevent the
37
+
arguments as the operation `SomeFunc` itself and can return an array containing `[ true, something ]`, which will cause
38
+
the installed method to simply return the object `something`, or `[ false ]`. If the output is `false`, the computation will
39
+
continue with the step Prefunction. Additionally, for every category and every name like `SomeFunc`, there is a boolean,
40
+
stored in the category's component `redirects` under the name of `SomeFunc`, which, when it is `false`, will prevent the
38
41
redirect function from being executed.
39
42
40
-
* Prefunction: The prefunction should be used for error handling and soft checks of the sanity of the input to SomeFunc
41
-
(e.g. for KernelLift it should check wether range and source of the morphims coincide). Generally, the prefunction is defined
42
-
in the method record and only depend on the name SomeFunc. It is called with the same input as the function itself, and
43
-
should return either [ true ], which continues the computation, or [ false, "message" ], which will cause an error with
44
-
message "message" and some additional information.
43
+
* Prefunction: The prefunction should be used for error handling and plausibility checks of the input to `SomeFunc`
44
+
(e.g. for `KernelLift` it should check wether range and source of the morphims coincide). Generally, the prefunction is defined
45
+
in the method record and only depends on the name `SomeFunc`. It is called with the same input as the function itself, and
46
+
should return either `[ true ]`, which continues the computation, or `[ false, "message" ]`, which will cause an error with
47
+
message `"message"` and some additional information.
45
48
46
49
* Full prefunction: The full prefuction has the same semantics as the prefunction, but can perform additional, very
47
50
costly checks. They are disabled by default.
48
51
49
52
* Function: This will launch the function(s) given as arguments. The result should be as specified in the type of
50
-
SomeFunc. The resulting object is now named the result.
53
+
`SomeFunc`. The resulting object is now named the result.
51
54
52
55
* Logic: For every function, some logical todos can be implemented in a logic texfile for the category. If there is
53
56
some logic written down in a file belonging to the category, or belonging to some type of category. Please see the
54
-
description of logic for more details. If there is some logic and some predicate relations for the function SomeFunc,
57
+
description of logic for more details. If there is some logic and some predicate relations for the function `SomeFunc`,
55
58
it is installed in this step for the result.
56
59
57
60
* Postfunction: The postfunction called with the arguments of the function and the result. It can be an arbitrary function doing
58
-
some cosmetics. If for example SomeFunc is KernelEmbedding, it will set the KernelObject of the input morphism to result.
59
-
The postfunction is also taken from the method record and does only depend on the name SomeFunc.
61
+
some cosmetics. If for example `SomeFunc` is `KernelEmbedding`, it will set the `KernelObject` of the input morphism to result.
62
+
The postfunction is also taken from the method record and does only depend on the name `SomeFunc`.
60
63
61
64
* Addfunction: If the result is a category cell, it is added to the category for which the function was installed.
65
+
This is disabled by default and can be enabled via <Ref Func="EnableAddForCategoricalOperations" />.
62
66
63
67
@Section Add Method
64
68
65
-
Except from installing a new method for the name SomeFunc, an Add method does slightly more.
69
+
Except from installing a new method for the name `SomeFunc`, an Add method does slightly more.
66
70
Every Add method has the same structure. The steps in the Add method are as follows:
67
71
68
72
* Weight check: If the current weight of the operation is lower than the given weight of the new functions,
69
73
then the add function returns and installs nothing.
70
74
71
-
* Option check: There are two possible options for every add method: SetPrimitive and IsDerivation.
72
-
* SetPrimitive should be a boolean, the default is true. If SetPrimitive is false, then the
75
+
* Option check: There are two possible options for every add method: `SetPrimitive` and `IsDerivation`.
76
+
* `SetPrimitive` should be a boolean, the default is true. If `SetPrimitive` is false, then the
73
77
current call of this add will not set the installed function to be primitive. This is used for derivations.
74
-
* IsDerivation should be a boolean, default is false. If it is true, the add method assumes that the given
78
+
* `IsDerivation` should be a boolean, default is false. If it is true, the add method assumes that the given
75
79
function is a derivation and does not try to install a corresponding pair (See below).
76
80
77
-
* Standard weight: If the weight parameter is -1, the Standard weight is assumed, which is 100.
78
-
79
-
* Checking for pairs: If the function is not a with given operation, has a corresponding with given or is a with given,
80
-
and is newly installed, i.e. the current installation weight which is given to the add function
81
-
is less than the current weight, the add method is going to install a corresponding pair function,
82
-
i.e. a function for the corresponding with or without given method, which redirects to the currently
83
-
installed functions. It also deactivates the redirect for this function.
84
-
Note that the pair install is only done for primitive functions, and if the current weight is
85
-
higher than the given weight.
86
-
87
-
* Can compute: Set the corresponding can compute of the category to true
81
+
* Default weight: If the weight parameter is -1, the default weight is assumed, which is 100.
88
82
89
-
* Install methods: Decide on the methods used to install the function. Check wether InstallMethodWithCache, InstallMethodWithToDoForIsWellDefined,
90
-
both, or simply InstallMethod is used. This is decided by the ToDo and the caching flags.
83
+
* Checking for pairs: If the function is part of a with given pair, we check if the weight of the with given operation
84
+
is less than or equal to the weight of the without given operation. If this is the case,
85
+
the redirect function for the without given operation is enabled, else disabled.
91
86
92
87
* Installation: Next, the method to install the functions is created. It creates the correct filter list, by merging the standard filters
93
88
for the operation with the particular filters for the given functions, then installs the method as described above.
94
89
95
90
* SetPrimitive: If the set primitive flag is true, it is set as primitive in the weight list of the category.
96
91
97
-
* Pair install: If there is a function pair, as described above, it is installed.
98
-
99
-
After calling an add method, the corresponding Operation is available in the category. Also, some derivations, which are triggered by the setting
92
+
After calling an add method, the corresponding operation is available in the category. Also, some derivations, which are triggered by the setting
100
93
of the primitive value, might be available.
101
94
102
95
103
96
@Section InstallAdd Function
97
+
@SectionLabel CapInternalInstallAdd
104
98
105
-
Almost all Add methods in the CAP kernel are installed by the CapInternalInstallAdd operation.
99
+
Almost all Add methods in the CAP kernel are installed by the `CapInternalInstallAdd` operation.
106
100
The definition of this function is as follows:
107
101
102
+
@BeginCode CapInternalInstallAdd
108
103
DeclareOperation( "CapInternalInstallAdd",
109
104
[ IsRecord ] );
105
+
@EndCode
106
+
107
+
@InsertCode CapInternalInstallAdd
110
108
111
-
The record can have the following components, used as described:
109
+
The record can have the following components, most of which can be set in the method name record, used as described:
112
110
113
111
* function_name: The name of the function. This does not have to coincide with the installation name. It is used for the derivation weight.
114
112
@@ -117,6 +115,8 @@ The record can have the following components, used as described:
117
115
118
116
* pre_function (optional): A function which is used as the prefunction of the installed methods, as described above.
119
117
118
+
* pre_function_full (optional): A function which is used as the full prefunction of the installed methods, as described above.
119
+
120
120
* redirect_function (optional): A function which is used as the redirect function of the installed methods, as described above.
121
121
122
122
* post_function (optional): A function which is used as the postfunction of the installed methods, as described above.
@@ -152,24 +152,37 @@ The record can have the following components, used as described:
152
152
used for the result of the computation. Otherwise, no <C>Add</C> function is used after all.
153
153
@InsertCode CAP_INTERNAL_VALID_RETURN_TYPES
154
154
155
-
* is_with_given: Boolean, marks whether the function which is to be installed is a with given function or not.
155
+
* is_with_given (optional): Boolean, marks whether the function which is to be installed is a with given function or not.
156
156
157
157
* with_given_without_given_name_pair (optional): If the currently installed operation has a corresponding with given operation or
158
158
is the with given of another operation, the names of both should be in this list.
159
159
160
-
* functorial (optional): If an object has a corresponding functorial function, e.g., KernelObject and KernelObjectFunctorial,
160
+
* functorial (optional): If an object has a corresponding functorial function, e.g., `KernelObject` and `KernelObjectFunctorial`,
161
161
the name of the functorial is stored as a string.
162
162
163
-
* dual_arguments_reversed: Boolean, marks whether for the call of the dual operation all arguments have to be given in reversed order.
163
+
* dual_arguments_reversed (optional): Boolean, marks whether for the call of the dual operation all arguments have to be given in reversed order.
164
+
165
+
* dual_preprocessor_func (optional): let f be an operation with dual operation g. For the automatic installation of g from f,
166
+
the arguments given to g are preprocessed by this given function.
167
+
168
+
* dual_postprocessor_func (optional): let f be an operation with dual operation g. For the automatic installation of g from f,
169
+
the computed value of f is postprocessed by the given function.
170
+
171
+
* input_arguments_names (optional): A duplicate free list (of the same length as `filter_list`) of strings.
172
+
For example, these strings will be used as the names of the arguments when automatically generating functions for this operation, e.g. in the opposite category.
164
173
165
-
* dual_preprocessor_func: let f be an operation with dual operation g. For the automatic installation of g from f, the arguments given to g are preprocessed by this given function.
174
+
* output_source_getter_string (optional): Only valid if the operation returns a morphism: a piece of GAP code which computes the source of the
175
+
returned morphism. The input arguments are available via the names given in `input_arguments_names`.
166
176
167
-
* dual_postprocessor_func: let f be an operation with dual operation g. For the automatic installation of g from f, the computed value of f is postprocessed by the given function.
177
+
* output_range_getter_string (optional): Only valid if the operation returns a morphism: a piece of GAP code which computes the range of the
178
+
returned morphism. The input arguments are available via the names given in `input_arguments_names`.
168
179
169
-
* zero_arguments_for_add_method: the add method of this operation should get a function without arguments
180
+
* with_given_object_position (optional): One of the following strings: `"Source"`, `"Range"`, or `"both"`.
181
+
Set for the without given operation in a with given pair. Describes whether the source resp. range are given
182
+
(as the last argument of the with given operation) or both (as the second and the last argument of the with given operation).
170
183
171
-
Using all those entries, the operation CapInternalInstallAdd installs add methods as described above. It first provides a
172
-
sanity check for all the entries described, then installs the Add method in 4 ways, with list or functions as second argument, and
184
+
Using all those entries, the operation `CapInternalInstallAdd` installs add methods as described above. It first provides plausibility
185
+
checks for all the entries described, then installs the Add method in 4 ways, with list or functions as second argument, and
173
186
with an optional third parameter for the weight.
174
187
175
188
@@ -182,7 +195,7 @@ The function CAP_INTERNAL_ENHANCE_NAME_RECORD can be applied to a method name re
182
195
* WithGiven special case: If the current entry belongs to a WithGiven operation or its without given pair, the with_given_without_given_name_pair is set.
183
196
Additionally, the with given flag of the WithGiven operation is set to true.
184
197
185
-
* Redirect and post functions are created for all operations belonging to universal constructions (e.g. KernelLift) which are not a WithGiven operation.
198
+
* Redirect and post functions are created for all operations belonging to universal constructions (e.g. `KernelLift`) which are not a WithGiven operation.
0 commit comments