From 343057580980a3469124ecb71ac53a10955995b1 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Tue, 16 Mar 2021 11:34:02 +0100 Subject: [PATCH 1/9] Add documentation for DirectSum and DirectProduct --- CAP/gap/UniversalObjects.gd | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CAP/gap/UniversalObjects.gd b/CAP/gap/UniversalObjects.gd index e0b1d2d25f..1e29b9506c 100644 --- a/CAP/gap/UniversalObjects.gd +++ b/CAP/gap/UniversalObjects.gd @@ -1344,6 +1344,15 @@ DeclareOperation( "AddInitialObjectFunctorial", ## Main Operations and Attributes +#! @Description +#! This is a convenience method. +#! There are two different ways to use this method: +#! * The argument is a list of objects $D = (S_1, \dots, S_n)$. +#! * The arguments are objects $S_1, \dots, S_n$. +#! The output is the direct sum $\bigoplus_{i=1}^n S_i$. +#! @Returns an object +# DeclareGlobalFunction( "DirectSum" ); # already defined by GAP + #! @Description #! The argument is a list of objects $D = (S_1, \dots, S_n)$. #! The output is the direct sum $\bigoplus_{i=1}^n S_i$. @@ -2239,6 +2248,16 @@ DeclareOperation( "AddCoproductFunctorialWithGivenCoproducts", ## Main Operations and Attributes + +#! @Description +#! This is a convenience method. +#! There are two different ways to use this method: +#! * The argument is a list of objects $D = ( P_1, \dots, P_n )$. +#! * The arguments are objects $P_1, \dots, P_n$. +#! The output is the direct product $\prod_{i=1}^n P_i$. +#! @Returns an object +# DeclareGlobalFunction( "DirectProduct" ); # already defined by GAP + #! @Description #! The argument is a list of objects $D = ( P_1, \dots, P_n )$. #! The output is the direct product $\prod_{i=1}^n P_i$. From 9fc5ca2104ed2cec1a70661e3153527c74473af5 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Thu, 18 Mar 2021 12:11:11 +0100 Subject: [PATCH 2/9] Deprecate some methods * For functorials we only support giving morphisms between targets ("target" in the sense of the chapter on Limits and Colimits in the manual). * Now that the category is available in every context, there is no need to pass category cells to Zero/Terminal/InitialObject anymore. * The convenience version of MorphismBetweenDirectSums is not used anywhere. --- CAP/gap/UniversalObjects.gi | 61 ++++++++++++++++++- .../examples/GradedRowsAndColumns.g | 4 +- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/CAP/gap/UniversalObjects.gi b/CAP/gap/UniversalObjects.gi index ea38bd7276..80e202e2ce 100644 --- a/CAP/gap/UniversalObjects.gi +++ b/CAP/gap/UniversalObjects.gi @@ -21,6 +21,13 @@ InstallMethod( KernelObjectFunctorial, function( morphism_of_morphisms ) + Print( + Concatenation( + "WARNING: KernelObjectFunctorial( IsList ) is deprecated and will not be supported after 2022.03.18. ", + "Please use KernelObjectFunctorial( IsCapCategoryMorphism, IsCapCategoryMorphism, IsCapCategoryMorphism ) instead.\n" + ) + ); + return KernelObjectFunctorialWithGivenKernelObjects( KernelObject( morphism_of_morphisms[1] ), morphism_of_morphisms[1], morphism_of_morphisms[2][1], morphism_of_morphisms[3], @@ -35,6 +42,15 @@ InstallMethod( KernelObjectFunctorialWithGivenKernelObjects, function( s, alpha, mu, nu, alpha_prime, r ) + Print( + Concatenation( + "WARNING: KernelObjectFunctorialWithGivenKernelObjects( IsCapCategoryObject, IsCapCategoryMorphism, IsCapCategoryMorphism, ", + "IsCapCategoryMorphism, IsCapCategoryMorphism, IsCapCategoryObject ) is deprecated and will not be supported after 2022.03.18. ", + "Please use KernelObjectFunctorialWithGivenKernelObjects( IsCapCategoryObject, IsCapCategoryMorphism, IsCapCategoryMorphism, ", + "IsCapCategoryMorphism, IsCapCategoryObject ) instead.\n" + ) + ); + return KernelObjectFunctorialWithGivenKernelObjects( s, alpha, mu, alpha_prime, r ); @@ -56,6 +72,13 @@ InstallMethod( CokernelObjectFunctorial, function( morphism_of_morphisms ) + Print( + Concatenation( + "WARNING: CokernelObjectFunctorial( IsList ) is deprecated and will not be supported after 2022.03.18. ", + "Please use CokernelObjectFunctorial( IsCapCategoryMorphism, IsCapCategoryMorphism, IsCapCategoryMorphism ) instead.\n" + ) + ); + return CokernelObjectFunctorialWithGivenCokernelObjects( CokernelObject( morphism_of_morphisms[1] ), morphism_of_morphisms[1], morphism_of_morphisms[2][2], morphism_of_morphisms[3], @@ -70,6 +93,15 @@ InstallMethod( CokernelObjectFunctorialWithGivenCokernelObjects, function( s, alpha, mu, nu, alpha_prime, r ) + Print( + Concatenation( + "WARNING: CokernelObjectFunctorialWithGivenCokernelObjects( IsCapCategoryObject, IsCapCategoryMorphism, IsCapCategoryMorphism, ", + "IsCapCategoryMorphism, IsCapCategoryMorphism, IsCapCategoryObject ) is deprecated and will not be supported after 2022.03.18. ", + "Please use CokernelObjectFunctorialWithGivenCokernelObjects( IsCapCategoryObject, IsCapCategoryMorphism, IsCapCategoryMorphism, ", + "IsCapCategoryMorphism, IsCapCategoryObject ) instead.\n" + ) + ); + return CokernelObjectFunctorialWithGivenCokernelObjects( s, alpha, nu, alpha_prime, r ); @@ -371,7 +403,6 @@ InstallMethod( MorphismBetweenDirectSums, end ); -## TODO: is this deprecated? ## InstallMethod( MorphismBetweenDirectSumsOp, [ IsList, IsInt, IsInt ], @@ -379,6 +410,13 @@ InstallMethod( MorphismBetweenDirectSumsOp, function( morphism_matrix_listlist, rows, cols ) local morphism_matrix, i, diagram_direct_sum_source, diagram_direct_sum_range, test_diagram_product, test_diagram_coproduct, morphism_into_product; + Print( + Concatenation( + "WARNING: MorphismBetweenDirectSums( IsList, IsInt, IsInt ) is deprecated and will not be supported after 2022.03.18. ", + "Please use MorphismBetweenDirectSums( IsList ) instead.\n" + ) + ); + morphism_matrix := [ ]; for i in [ 1 .. rows ] do @@ -407,6 +445,13 @@ InstallMethod( ZeroObject, function( cell ) + Print( + Concatenation( + "WARNING: ZeroObject( IsCapCategoryCell ) is deprecated and will not be supported after 2022.03.18. ", + "Please use ZeroObject( IsCapCategory ) instead.\n" + ) + ); + return ZeroObject( CapCategory( cell ) ); end ); @@ -447,6 +492,13 @@ InstallMethod( TerminalObject, function( cell ) + Print( + Concatenation( + "WARNING: TerminalObject( IsCapCategoryCell ) is deprecated and will not be supported after 2022.03.18. ", + "Please use TerminalObject( IsCapCategory ) instead.\n" + ) + ); + return TerminalObject( CapCategory( cell ) ); end ); @@ -467,6 +519,13 @@ InstallMethod( InitialObject, function( cell ) + Print( + Concatenation( + "WARNING: InitialObject( IsCapCategoryCell ) is deprecated and will not be supported after 2022.03.18. ", + "Please use InitialObject( IsCapCategory ) instead.\n" + ) + ); + return InitialObject( CapCategory( cell ) ); end ); diff --git a/FreydCategoriesForCAP/examples/GradedRowsAndColumns.g b/FreydCategoriesForCAP/examples/GradedRowsAndColumns.g index 13bd68de83..067bc7c2f0 100644 --- a/FreydCategoriesForCAP/examples/GradedRowsAndColumns.g +++ b/FreydCategoriesForCAP/examples/GradedRowsAndColumns.g @@ -1124,7 +1124,7 @@ Display( InternalHomOnObjects( ObjectR, ObjectR ) ); #! @Example aR := GradedRow( [ [ [1,0], 1 ] ], S ); #! -bR := ZeroObject( aR ); +bR := ZeroObject( CapCategory( aR ) ); #! coevR := CoevaluationForDual( bR ); #! -bC := ZeroObject( aC ); +bC := ZeroObject( CapCategory( aC ) ); #! coevC := CoevaluationForDual( bC ); #! Date: Mon, 22 Mar 2021 09:34:46 +0100 Subject: [PATCH 3/9] Fix typo --- CAP/gap/UniversalObjects.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CAP/gap/UniversalObjects.gd b/CAP/gap/UniversalObjects.gd index 1e29b9506c..da72d29ee1 100644 --- a/CAP/gap/UniversalObjects.gd +++ b/CAP/gap/UniversalObjects.gd @@ -3876,7 +3876,7 @@ DeclareOperation( "AddDirectSumProjectionInPushout", [ IsCapCategory, IsList ] ); #! @Description -#! The argument is a list of morphisms $D = ( \beta_i: B \rightarrow I_i )_{i = 1 \dots n}$ +#! The argument is a list of morphisms $D = ( \beta_i: B \rightarrow I_i )_{i = 1 \dots n}$. #! The output is the pushout $\mathrm{Pushout}(D)$. #! @Returns an object #! @Arguments D From 8e78307ea9b4b94492ea4c671612284a4d83c60c Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Fri, 26 Mar 2021 16:09:56 +0100 Subject: [PATCH 4/9] Additional checks for automatic redirections and with given derivations Also make the existing checks more readable --- CAP/gap/InstallAdds.gi | 12 ++++++++++-- CAP/gap/MethodRecord.gi | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CAP/gap/InstallAdds.gi b/CAP/gap/InstallAdds.gi index da91f99024..7e9e88de51 100644 --- a/CAP/gap/InstallAdds.gi +++ b/CAP/gap/InstallAdds.gi @@ -626,12 +626,12 @@ BindGlobal( "CAP_INTERNAL_INSTALL_WITH_GIVEN_DERIVATIONS", function( record ) if current_rec.is_with_given then without_given_name := current_rec.with_given_without_given_name_pair[1]; - with_given_name := current_recname; + with_given_name := current_rec.with_given_without_given_name_pair[2]; object_name := current_rec.universal_object; # first argument is the category object_arguments := [ 1 .. current_rec.number_of_diagram_arguments + 1 ]; - if current_rec.filter_list[1] <> "category" or record.( object_name ).filter_list[1] <> "category" or record.( without_given_name ).filter_list[1] <> "category" then + if record.( without_given_name ).filter_list[1] <> "category" or record.( object_name ).filter_list[1] <> "category" or record.( with_given_name ).filter_list[1] <> "category" then Display( Concatenation( "WARNING: You seem to be relying on automatically installed WithGiven derivations but the first arguments of the functions involved are not the category. ", @@ -640,6 +640,14 @@ BindGlobal( "CAP_INTERNAL_INSTALL_WITH_GIVEN_DERIVATIONS", function( record ) "Search for `category_as_first_argument` in the documentation for more details." ) ); + elif Length( record.( without_given_name ).filter_list ) + 1 <> Length( record.( with_given_name ).filter_list ) then + + Display( Concatenation( + "WARNING: You seem to be relying on automatically installed WithGiven derivations. ", + "For this, the with given method must have exactly one additional argument compared to the without given method. ", + "This is not the case, so no automatic WithGiven derivation will be installed." + ) ); + else CAP_INTERNAL_INSTALL_WITH_GIVEN_DERIVATION_PAIR( without_given_name, with_given_name, object_name, object_arguments ); diff --git a/CAP/gap/MethodRecord.gi b/CAP/gap/MethodRecord.gi index 8a7d23755c..925b2f08d3 100644 --- a/CAP/gap/MethodRecord.gi +++ b/CAP/gap/MethodRecord.gi @@ -4628,7 +4628,9 @@ InstallGlobalFunction( CAP_INTERNAL_ENHANCE_NAME_RECORD, ## FIXME: If the redirect function is already bound, then this part is superfluous - with_given_name := Concatenation( current_recname, "WithGiven" ); + without_given_name := current_recname; + + with_given_name := Concatenation( without_given_name, "WithGiven" ); with_given_name_length := Length( with_given_name ); @@ -4650,7 +4652,7 @@ InstallGlobalFunction( CAP_INTERNAL_ENHANCE_NAME_RECORD, fi; - current_rec.with_given_without_given_name_pair := [ current_recname, with_given_name ]; + current_rec.with_given_without_given_name_pair := [ without_given_name, with_given_name ]; object_name := with_given_name{[ with_given_name_length + 1 .. Length( with_given_name ) ]}; @@ -4667,7 +4669,7 @@ InstallGlobalFunction( CAP_INTERNAL_ENHANCE_NAME_RECORD, if not IsBound( current_rec.redirect_function ) then - if current_rec.filter_list[1] <> "category" or record.( object_name ).filter_list[1] <> "category" or record.( with_given_name ).filter_list[1] <> "category" then + if record.( without_given_name ).filter_list[1] <> "category" or record.( object_name ).filter_list[1] <> "category" or record.( with_given_name ).filter_list[1] <> "category" then Display( Concatenation( "WARNING: You seem to be relying on automatically installed redirect functions but the first arguments of the functions involved are not the category. ", @@ -4676,6 +4678,15 @@ InstallGlobalFunction( CAP_INTERNAL_ENHANCE_NAME_RECORD, "Search for `category_as_first_argument` in the documentation for more details." ) ); + elif Length( record.( without_given_name ).filter_list ) + 1 <> Length( record.( with_given_name ).filter_list ) then + + Display( Concatenation( + "WARNING: You seem to be relying on automatically installed redirect functions. ", + "For this, the with given method must have exactly one additional argument compared to the without given method. ", + "This is not the case, so no automatic redirect function will be installed. ", + "Install a custom redirect function to prevent this warning." + ) ); + else current_rec.redirect_function := CAP_INTERNAL_CREATE_REDIRECTION( with_given_name, object_func, object_arg_list, object_func ); From bf757d5f1e4bfe47b34524348435d5dc0d0087b5 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Mon, 12 Apr 2021 15:57:10 +0200 Subject: [PATCH 5/9] Add plausibility check to opposite category --- CAP/gap/OppositeCategory.gi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CAP/gap/OppositeCategory.gi b/CAP/gap/OppositeCategory.gi index cb02f4f1c6..314b90d990 100644 --- a/CAP/gap/OppositeCategory.gi +++ b/CAP/gap/OppositeCategory.gi @@ -259,6 +259,12 @@ BindGlobal( "CAP_INTERNAL_INSTALL_OPPOSITE_ADDS_FROM_CATEGORY", dual_name := current_entry.dual_operation; + if not IsBound( CAP_INTERNAL_METHOD_NAME_RECORD.( dual_name ) ) then + + Error( "the dual operation must be a CAP operation" ); + + fi; + if CurrentOperationWeight( category_weight_list, dual_name ) = infinity then continue; fi; From d53e0199fc550f57d8167d0dc484e06da40e5678 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Mon, 12 Apr 2021 18:11:42 +0200 Subject: [PATCH 6/9] Add plausibility check to GET_METHOD_CACHE --- CAP/gap/CAP.gi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CAP/gap/CAP.gi b/CAP/gap/CAP.gi index 2aaf8fe72f..3aeed3f641 100644 --- a/CAP/gap/CAP.gi +++ b/CAP/gap/CAP.gi @@ -55,6 +55,13 @@ InstallGlobalFunction( GET_METHOD_CACHE, if IsBound( category!.caches.( name ) ) and IsCachingObject( category!.caches.( name ) ) then + if category!.caches.( name )!.nr_keys <> number then + + Error( "you have requested a cache for \"", name, "\" with ", number, + " keys but the existing cache with the same name has ", category!.caches.( name )!.nr_keys, " keys" ); + + fi; + return category!.caches.( name ); fi; From bffe7566da7063ce0e4554bd089414486808859e Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Fri, 26 Mar 2021 16:56:22 +0100 Subject: [PATCH 7/9] Update documentation to current implementation --- CAP/doc/AddFunctions.autodoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CAP/doc/AddFunctions.autodoc b/CAP/doc/AddFunctions.autodoc index 180d8f40ed..f03c46e8cc 100644 --- a/CAP/doc/AddFunctions.autodoc +++ b/CAP/doc/AddFunctions.autodoc @@ -162,7 +162,7 @@ The record can have the following components, used as described: * functorial (optional): If an object has a corresponding functorial function, e.g., KernelObject and KernelObjectFunctorial, the name of the functorial is stored as a string. -* number_of_diagram_arguments: Specifies how many of the arguments (counting from the first argument) of the function specify the diagram of the universal object. +* number_of_diagram_arguments: Specifies how many of the arguments (counting from the second argument, assuming that the first is the category) of the function specify the diagram of the universal object. * dual_arguments_reversed: Boolean, marks whether for the call of the dual operation all arguments have to be given in reversed order. From c6796316012cc3e28f4e3c3d4f9725ce0c63f48d Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Mon, 22 Mar 2021 17:25:27 +0100 Subject: [PATCH 8/9] Remove obsolete code This code has no effect since 137b5aab373200f3fa1afde3f92d2dd865b47310 --- CAP/gap/MethodRecord.gi | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CAP/gap/MethodRecord.gi b/CAP/gap/MethodRecord.gi index 925b2f08d3..fcd46ec8b2 100644 --- a/CAP/gap/MethodRecord.gi +++ b/CAP/gap/MethodRecord.gi @@ -4394,8 +4394,8 @@ end ); BindGlobal( "CAP_INTERNAL_CREATE_POST_FUNCTION", - function( source_range_object, object_function_name, object_arg_list, object_call_name, object_cache_name ) - local object_getter, diagram_name, setter_function, is_attribute, cache_key_length; + function( source_range_object, object_function_name, object_arg_list, object_cache_name ) + local object_getter, setter_function, is_attribute, cache_key_length; if source_range_object = "Source" then object_getter := Source; @@ -4405,7 +4405,6 @@ BindGlobal( "CAP_INTERNAL_CREATE_POST_FUNCTION", Error( "the first argument of CAP_INTERNAL_CREATE_POST_FUNCTION must be 'Source' or 'Range'" ); fi; - diagram_name := Concatenation( object_call_name, "Diagram" ); setter_function := Setter( ValueGlobal( object_function_name ) ); is_attribute := setter_function <> false; cache_key_length := Length( object_arg_list ); @@ -4708,7 +4707,7 @@ InstallGlobalFunction( CAP_INTERNAL_ENHANCE_NAME_RECORD, else - current_rec.post_function := CAP_INTERNAL_CREATE_POST_FUNCTION( current_rec.universal_object_position, object_func, object_arg_list, object_name, object_func ); + current_rec.post_function := CAP_INTERNAL_CREATE_POST_FUNCTION( current_rec.universal_object_position, object_func, object_arg_list, object_func ); fi; From dc05bbd0a93dede30a505a7459fd2fc291f752d1 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Tue, 13 Apr 2021 15:00:28 +0200 Subject: [PATCH 9/9] Add new plausibility checks regarding additional filter lists Also improve existing one. --- CAP/gap/Derivations.gi | 9 ++++++++- CAP/gap/Finalize.gi | 9 ++++++++- CAP/gap/InstallAdds.gi | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CAP/gap/Derivations.gi b/CAP/gap/Derivations.gi index e3195aece5..23dc644ea3 100644 --- a/CAP/gap/Derivations.gi +++ b/CAP/gap/Derivations.gi @@ -219,7 +219,7 @@ end ); InstallMethod( AddDerivation, [ IsDerivedMethodGraphRep, IsDerivedMethod ], function( G, d ) - local method_name, filter_list, number_of_proposed_arguments, current_function_argument_number, impl, op_name; + local method_name, filter_list, number_of_proposed_arguments, current_function_argument_number, current_additional_filter_list_length, impl, op_name; if IsIdenticalObj( G, CAP_INTERNAL_DERIVATION_GRAPH ) then @@ -244,6 +244,13 @@ function( G, d ) " arguments but should have ", String( number_of_proposed_arguments ) ); fi; + current_additional_filter_list_length := Length( impl[ 2 ] ); + + if current_additional_filter_list_length > 0 and current_additional_filter_list_length <> number_of_proposed_arguments then + Error( "While adding a derivation for ", method_name, ": there are ", String( current_additional_filter_list_length ), + " additional filters but there should be ", String( number_of_proposed_arguments ), " (or none)" ); + fi; + od; if NumberArgumentsFunction( CategoryFilter( d ) ) = 0 or NumberArgumentsFunction( CategoryFilter( d ) ) > 1 then diff --git a/CAP/gap/Finalize.gi b/CAP/gap/Finalize.gi index 1c265385fa..558ee8ea83 100644 --- a/CAP/gap/Finalize.gi +++ b/CAP/gap/Finalize.gi @@ -9,7 +9,7 @@ InstallValue( CAP_INTERNAL_FINAL_DERIVATION_LIST, BindGlobal( "CAP_INTERNAL_FINAL_DERIVATION_SANITY_CHECK", function( derivation ) - local possible_names, all_operations, function_object, function_string, string_stream, methods_to_check, method_name, filter_list, number_of_proposed_arguments, current_function_argument_number, i, method, impl; + local possible_names, all_operations, function_object, function_string, string_stream, methods_to_check, method_name, filter_list, number_of_proposed_arguments, current_function_argument_number, current_additional_filter_list_length, i, method, impl; possible_names := derivation!.can_compute; @@ -72,6 +72,13 @@ BindGlobal( "CAP_INTERNAL_FINAL_DERIVATION_SANITY_CHECK", " arguments but should have ", String( number_of_proposed_arguments ) ); fi; + current_additional_filter_list_length := Length( impl[ 2 ] ); + + if current_additional_filter_list_length > 0 and current_additional_filter_list_length <> number_of_proposed_arguments then + Error( "While adding a final derivation for ", method_name, ": there are ", String( current_additional_filter_list_length ), + " additional filters but there should be ", String( number_of_proposed_arguments ), " (or none)" ); + fi; + od; od; diff --git a/CAP/gap/InstallAdds.gi b/CAP/gap/InstallAdds.gi index 7e9e88de51..50334ef29b 100644 --- a/CAP/gap/InstallAdds.gi +++ b/CAP/gap/InstallAdds.gi @@ -284,8 +284,8 @@ InstallGlobalFunction( CapInternalInstallAdd, current_additional_filter_list_length := Length( method_list[ current_function_number ][ 2 ] ); if current_additional_filter_list_length > 0 and current_additional_filter_list_length <> number_of_proposed_arguments then - Error( "In ", add_name, ": the additional filter list of given function ", String( current_function_number ), - " has length ", String( current_additional_filter_list_length ), " but should have ", String( number_of_proposed_arguments ) ); + Error( "In ", add_name, ": the additional filter list of given function ", String( current_function_number ), " has length ", + String( current_additional_filter_list_length ), " but should have length ", String( number_of_proposed_arguments ), " (or 0)" ); fi; fi;