Skip to content

Commit 1a2f29a

Browse files
committed
Improve and extend AddFunctions.autodoc
1 parent cdb4942 commit 1a2f29a

File tree

2 files changed

+72
-51
lines changed

2 files changed

+72
-51
lines changed

CAP/doc/AddFunctions.autodoc

Lines changed: 64 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ This section describes the overall structure of Add-functions and the functions
44

55
@Section Functions Installed by Add
66

7-
Add functions (up to some exceptions) have the following syntax
7+
Add functions have the following syntax:
88

9+
@BeginCode AddSomeFunc
910
DeclareOperation( "AddSomeFunc",
1011
[ IsCapCategory, IsList, IsInt ] );
12+
@EndCode
1113

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`)
1317
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.
1620
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).
1922

2023
All installed methods follow the following steps, described below:
2124
* Redirect function
@@ -25,90 +28,85 @@ All installed methods follow the following steps, described below:
2528
* Postfunction
2629
* Addfunction
2730

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.
2932

3033
* Redirect function: The redirect is used to redirect the computation from the given functions to some other symbol.
3134
If there is for example a with given method for some universal property, and the universal object is already computed,
3235
the redirect function might detect such a thing, calls the with given operation with the universal object as additional
3336
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
3841
redirect function from being executed.
3942

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.
4548

4649
* Full prefunction: The full prefuction has the same semantics as the prefunction, but can perform additional, very
4750
costly checks. They are disabled by default.
4851

4952
* 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.
5154

5255
* Logic: For every function, some logical todos can be implemented in a logic texfile for the category. If there is
5356
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`,
5558
it is installed in this step for the result.
5659

5760
* 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`.
6063

6164
* 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" />.
6266

6367
@Section Add Method
6468

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.
6670
Every Add method has the same structure. The steps in the Add method are as follows:
6771

6872
* Weight check: If the current weight of the operation is lower than the given weight of the new functions,
6973
then the add function returns and installs nothing.
7074

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
7377
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
7579
function is a derivation and does not try to install a corresponding pair (See below).
7680

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.
8882

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.
9186

9287
* Installation: Next, the method to install the functions is created. It creates the correct filter list, by merging the standard filters
9388
for the operation with the particular filters for the given functions, then installs the method as described above.
9489

9590
* SetPrimitive: If the set primitive flag is true, it is set as primitive in the weight list of the category.
9691

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
10093
of the primitive value, might be available.
10194

10295

10396
@Section InstallAdd Function
97+
@SectionLabel CapInternalInstallAdd
10498

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.
106100
The definition of this function is as follows:
107101

102+
@BeginCode CapInternalInstallAdd
108103
DeclareOperation( "CapInternalInstallAdd",
109104
[ IsRecord ] );
105+
@EndCode
106+
107+
@InsertCode CapInternalInstallAdd
110108

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:
112110

113111
* function_name: The name of the function. This does not have to coincide with the installation name. It is used for the derivation weight.
114112

@@ -117,6 +115,8 @@ The record can have the following components, used as described:
117115

118116
* pre_function (optional): A function which is used as the prefunction of the installed methods, as described above.
119117

118+
* pre_function_full (optional): A function which is used as the full prefunction of the installed methods, as described above.
119+
120120
* redirect_function (optional): A function which is used as the redirect function of the installed methods, as described above.
121121

122122
* 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:
152152
used for the result of the computation. Otherwise, no <C>Add</C> function is used after all.
153153
@InsertCode CAP_INTERNAL_VALID_RETURN_TYPES
154154

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.
156156

157157
* with_given_without_given_name_pair (optional): If the currently installed operation has a corresponding with given operation or
158158
is the with given of another operation, the names of both should be in this list.
159159

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`,
161161
the name of the functorial is stored as a string.
162162

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.
164173

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`.
166176

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`.
168179

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).
170183

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
173186
with an optional third parameter for the weight.
174187

175188

@@ -182,7 +195,7 @@ The function CAP_INTERNAL_ENHANCE_NAME_RECORD can be applied to a method name re
182195
* 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.
183196
Additionally, the with given flag of the WithGiven operation is set to true.
184197

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.
186199

187200

188201
@Section Install All Adds

CAP/gap/InstallAdds.gd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
#
44
# Declarations
55
#
6+
7+
#! @Chapter Add Functions
8+
9+
#! @Section InstallAdd Function
10+
11+
#! @Description
12+
#! See <Ref Sect="Section_CapInternalInstallAdd" />.
13+
#! @Arguments record
614
DeclareGlobalFunction( "CapInternalInstallAdd" );
715

816
DeclareGlobalFunction( "CAP_INTERNAL_INSTALL_ADDS_FROM_RECORD" );

0 commit comments

Comments
 (0)