Skip to content

Commit

Permalink
Merge pull request #649 from zickgraf/category_as_first_argument
Browse files Browse the repository at this point in the history
Allow to pass the category as the first argument to any CAP operation
  • Loading branch information
sebastianpos authored Apr 12, 2021
2 parents cddfb2c + 0d5b82c commit e583a56
Show file tree
Hide file tree
Showing 49 changed files with 1,525 additions and 1,954 deletions.
2 changes: 1 addition & 1 deletion CAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Version := Maximum( [
## this line prevents merge conflicts
"2020.04-16", ## Sepp's version
## this line prevents merge conflicts
"2020.10-01", ## Fabian's version
"2021.03-01", ## Fabian's version
## this line prevents merge conflicts
"2020.08-01", ## Kamal's version
] ),
Expand Down
20 changes: 4 additions & 16 deletions CAP/doc/AddFunctions.autodoc
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,11 @@ The record can have the following components, used as described:
* post_function (optional): A function which is used as the postfunction of the installed methods, as described above.

* filter_list: A list containing the basic filters for the methods installed by the add methods. Possible entries are filters, or
the following strings, which will be replaced by appropriate filters at the time the add method is called.
the strings listed below, which will be replaced by appropriate filters at the time the add method is called.
Additionally, an entry can be a list consisting of filters and/or the given strings, which will then be joined via `and` to form a single filter.
If the first filter is <C>category</C> and the category can be inferred from the remaining arguments, a convenience method without the category
as the first argument is installed automatically. Additionally, the category is not passed to primitively added functions, except if
`category!.category_as_first_argument` is set to `true` (this will probably change to be the default in the future).
* <C>category</C>,
* <C>cell</C>,
* <C>object</C>,
Expand All @@ -146,11 +149,6 @@ The record can have the following components, used as described:
* cache_name (optional): The name of the cache which is used for the installed methods. If no cache name is given, the caching
for the operation is deactivated completely.

* argument_list (optional): A list containing integers, which defines which arguments should be used for the additional functions, (e.g redirect, pre, ...).
This is important for the Op method contructions. If no argument list is given, all arguments are used.
Please note that if you have a method selection argument for your function, you need to give the argument_list
to explicitly state which argument is the method selection argument.

* return_type: The return type can either be a filter or one of the strings in the list below.
For objects, morphisms and $2$-cells the correct <C>Add</C> function (see above) is
used for the result of the computation. Otherwise, no <C>Add</C> function is used after all.
Expand Down Expand Up @@ -187,19 +185,9 @@ The function CAP_INTERNAL_ENHANCE_NAME_RECORD can be applied to a method name re

* Function name: Set the component function_name to the entry name.

* Redirect and post functions: Since the redirect and post functions need the category to work correctly, the given functions in the method records are
packed up to discard the first argument (which is the category) if necessary.

* universal_object_arg_list: An argument list for redirect and post functions is created, by looking at the filter list in the record.
If the number of diagram arguments is zero, the first argument is used.
If all diagram arguments are lists, the diagram arguments and additionally the last argument (method selection argument) are used.
Otherwise, the diagram arguments are used.

* 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.
Additionally, the with given flag of the WithGiven operation is set to true.

* argument_list: If argument_list is not bound, it is set to include all arguments.

* Redirect and post functions are created for all operations belonging to universal constructions (e.g. KernelLift) which are not a WithGiven operation.


Expand Down
8 changes: 0 additions & 8 deletions CAP/gap/CategoryMorphisms.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1933,10 +1933,6 @@ DeclareOperation( "AddInterpretMorphismFromDistinguishedObjectToHomomorphismStru
DeclareOperation( "AddInterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism",
[ IsCapCategory, IsList ] );

##
DeclareOperation( "SolveLinearSystemInAbCategoryOp",
[ IsList, IsList, IsList, IsCapCategory ] );

#! @Description
#! The arguments are three lists $\alpha$, $\beta$, and $\gamma$.
#! The first list $\alpha$ (the left coefficients) is a list of list of morphisms $\alpha_{ij}: A_i \rightarrow B_j$,
Expand Down Expand Up @@ -1968,10 +1964,6 @@ DeclareOperation( "AddSolveLinearSystemInAbCategory",
DeclareOperation( "AddSolveLinearSystemInAbCategory",
[ IsCapCategory, IsList ] );

##
DeclareOperation( "MereExistenceOfSolutionOfLinearSystemInAbCategoryOp",
[ IsList, IsList, IsList, IsCapCategory ] );

#! @Description
#! Like <C>SolveLinearSystemInAbCategory</C>,
#! but the output is simply <C>true</C> if a solution exists,
Expand Down
33 changes: 13 additions & 20 deletions CAP/gap/CategoryMorphisms.gi
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ InstallMethod( AdditiveInverse,

AdditiveInverseForMorphisms );

##
InstallOtherMethod( InverseImmutable,
[ IsCapCategory, IsCapCategoryMorphism ],

InverseOp );

##
InstallMethod( \*,
[ IsRingElement, IsCapCategoryMorphism ],
Expand Down Expand Up @@ -220,7 +226,14 @@ InstallMethod( IsEqualForCacheForMorphisms,

IsEqualForCache );

##
# generic fallback to IsIdenticalObj
InstallOtherMethod( IsEqualForCache,
[ IsCapCategory, IsCapCategoryMorphism, IsCapCategoryMorphism ],

{ cat, mor1, mor2 } -> IsIdenticalObj( mor1, mor2 ) );

##
InstallMethod( AddMorphismRepresentation,
[ IsCapCategory, IsObject ],

Expand Down Expand Up @@ -512,26 +525,6 @@ InstallMethod( HomomorphismStructureOnMorphisms,

end );

##
InstallMethod( SolveLinearSystemInAbCategory,
[ IsList, IsList, IsList ],

function( left_coeffs, right_coeffs, right_side )

return SolveLinearSystemInAbCategoryOp( left_coeffs, right_coeffs, right_side, CapCategory( right_side[1] ) );

end );

##
InstallMethod( MereExistenceOfSolutionOfLinearSystemInAbCategory,
[ IsList, IsList, IsList ],

function( left_coeffs, right_coeffs, right_side )

return MereExistenceOfSolutionOfLinearSystemInAbCategoryOp( left_coeffs, right_coeffs, right_side, CapCategory( right_side[1] ) );

end );

##
InstallMethod( HomStructure,
[ IsCapCategoryMorphism, IsCapCategoryMorphism ],
Expand Down
8 changes: 8 additions & 0 deletions CAP/gap/CategoryObjects.gi
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ InstallMethod( IsEqualForCacheForObjects,

IsEqualForCache );

##
# generic fallback to IsIdenticalObj
InstallOtherMethod( IsEqualForCache,
[ IsCapCategory, IsCapCategoryObject, IsCapCategoryObject ],

{ cat, obj1, obj2 } -> IsIdenticalObj( obj1, obj2 ) );

##
InstallMethod( AddObjectRepresentation,
[ IsCapCategory, IsObject ],

Expand Down
36 changes: 35 additions & 1 deletion CAP/gap/Derivations.gi
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,41 @@ end );
InstallMethod( AddDerivation,
[ IsDerivedMethodGraphRep, IsDerivedMethod ],
function( G, d )
local op_name;
local method_name, filter_list, number_of_proposed_arguments, current_function_argument_number, impl, op_name;

if IsIdenticalObj( G, CAP_INTERNAL_DERIVATION_GRAPH ) then

method_name := TargetOperation( d );

if not method_name in RecNames( CAP_INTERNAL_METHOD_NAME_RECORD ) then

Error( "trying to add a derivation to CAP_INTERNAL_DERIVATION_GRAPH for a method not in CAP_INTERNAL_METHOD_NAME_RECORD" );

fi;

filter_list := CAP_INTERNAL_METHOD_NAME_RECORD!.(method_name).filter_list;

number_of_proposed_arguments := Length( filter_list );

for impl in DerivationFunctionsWithExtraFilters( d ) do

current_function_argument_number := NumberArgumentsFunction( impl[ 1 ] );

if current_function_argument_number >= 0 and current_function_argument_number <> number_of_proposed_arguments then
Error( "While adding a derivation for ", method_name, ": given function has ", String( current_function_argument_number ),
" arguments but should have ", String( number_of_proposed_arguments ) );
fi;

od;

if NumberArgumentsFunction( CategoryFilter( d ) ) = 0 or NumberArgumentsFunction( CategoryFilter( d ) ) > 1 then

Error( "the CategoryFilter of a derivation must accept exactly one argument" );

fi;

fi;

Add( G!.derivations_by_target.( TargetOperation( d ) ), d );
for op_name in UsedOperations( d ) do
Add( G!.derivations_by_used_ops.( op_name ), d );
Expand Down
Loading

0 comments on commit e583a56

Please sign in to comment.