diff --git a/CAP/gap/CategoryConstructor.gd b/CAP/gap/CategoryConstructor.gd
index 5eb3b4c11c..cbdb8fe017 100644
--- a/CAP/gap/CategoryConstructor.gd
+++ b/CAP/gap/CategoryConstructor.gd
@@ -36,10 +36,10 @@ DeclareInfoClass( "InfoCategoryConstructor" );
#! * `morphism_constructor` (optional): function added as an installation of to the category
#! * `morphism_datum` (optional): function added as an installation of to the category
#! * `list_of_operations_to_install` (mandatory): a list of names of ∩ operations which should be installed for the category
-#! * `operation_weights` (optional): a record mapping operations in `list_of_operations_to_install` to their weights
#! * `is_computable` (optional): whether the category can decide `IsCongruentForMorphisms`
#! * `supports_empty_limits` (optional): whether the category supports empty lists in inputs to operations of limits and colimits
#! * `underlying_category_getter_string` (optional): see below
+#! * `underlying_category` (optional): see below
#! * `underlying_object_getter_string` (optional): see below
#! * `underlying_morphism_getter_string` (optional): see below
#! * `top_object_getter_string` (optional): see below
@@ -53,8 +53,9 @@ DeclareInfoClass( "InfoCategoryConstructor" );
#!
#! The values of the keys `create_func_*` should be either the string `"default`" or functions which accept the category and the name of a ∩ operation
#! of the corresponding `return_type`. Values for return types occuring for operations in `list_of_operations_to_install` are mandatory.
-#! The functions must return strings, which (after some replacements described below) will be evaluated and added as an installation of the corresponding operation to the category.
-#! The value `"default"` chooses a suitable default string, see the implementation for details.
+#! The functions must return either strings or pairs of a string and an integer:
+#! The strings (after some replacements described below) will be evaluated and added as installations of the corresponding operations to the category with weights given by the integer (if provided).
+#! The value `"default"` chooses a suitable default string (see the implementation for details) and gets the weights from `underlying_category`.
#! The following placeholders may be used in the strings and are replaced automatically:
#! * `operation_name` will be replaced by the name of the operation
#! * `input_arguments...` will be replaced by the `input_arguments_names` specified in the method name record (see )
diff --git a/CAP/gap/CategoryConstructor.gi b/CAP/gap/CategoryConstructor.gi
index f94af32c84..06925d6f49 100644
--- a/CAP/gap/CategoryConstructor.gi
+++ b/CAP/gap/CategoryConstructor.gi
@@ -9,7 +9,7 @@ InstallMethod( CategoryConstructor,
[ IsRecord ],
function( options )
- local known_options_with_filters, name, object_datum_type, morphism_datum_type, is_computable, filter, CC, default_func_strings, info, unknown_filters, create_func_name, create_func, func_string, underlying_arguments, add, func, option_name, prop;
+ local known_options_with_filters, name, object_datum_type, morphism_datum_type, is_computable, filter, CC, underlying_category, default_func_strings, info, unknown_filters, create_func_name, create_func, func_string, weight, func_string_and_weight, underlying_arguments, add, func, option_name, prop;
## check given options
known_options_with_filters := rec(
@@ -27,10 +27,10 @@ InstallMethod( CategoryConstructor,
morphism_constructor := IsFunction,
morphism_datum := IsFunction,
list_of_operations_to_install := IsList,
- operation_weights := IsRecord,
is_computable := IsBool,
supports_empty_limits := IsBool,
underlying_category_getter_string := IsString,
+ underlying_category := IsCapCategory,
underlying_object_getter_string := IsString,
underlying_morphism_getter_string := IsString,
top_object_getter_string := IsString,
@@ -290,11 +290,32 @@ InstallMethod( CategoryConstructor,
if create_func = "default" then
+ if not IsBound( options.underlying_category ) then
+
+ Error( "when using \"default\" for some `create_func_*`, the option `underlying_category` must be set" );
+
+ fi;
+
func_string := default_func_strings.(info.return_type);
+ # the default strings simply apply the operation in the underlying category
+ weight := OperationWeight( options.underlying_category, info.function_name );
+
elif IsFunction( create_func ) then
- func_string := create_func( name, CC );
+ func_string_and_weight := create_func( name, CC );
+
+ if IsList( func_string_and_weight ) and Length( func_string_and_weight ) = 2 and IsInt( func_string_and_weight[2] ) then
+
+ func_string := func_string_and_weight[1];
+ weight := func_string_and_weight[2];
+
+ else
+
+ func_string := func_string_and_weight;
+ weight := -1;
+
+ fi;
else
@@ -464,9 +485,9 @@ InstallMethod( CategoryConstructor,
func := EvalString( func_string );
- if IsBound( options.operation_weights ) and IsBound( options.operation_weights.(name) ) then
+ if weight <> -1 then
- add( CC, func, options.operation_weights.(name) );
+ add( CC, func, weight );
else
diff --git a/CAP/gap/DummyImplementations.gi b/CAP/gap/DummyImplementations.gi
index f2852e30ed..eb4d8c568d 100644
--- a/CAP/gap/DummyImplementations.gi
+++ b/CAP/gap/DummyImplementations.gi
@@ -166,13 +166,13 @@ InstallMethod( DummyCategory,
fi;
- dummy_function := { operation_name, dummy } -> """
+ dummy_function := { operation_name, dummy } -> Pair( """
function ( input_arguments... )
Error( "this is a dummy category without actual implementation" );
end
- """;
+ """, 1 );
category_constructor_options.create_func_bool := dummy_function;
category_constructor_options.create_func_object := dummy_function;
diff --git a/CAP/gap/ReinterpretationOfCategory.gi b/CAP/gap/ReinterpretationOfCategory.gi
index eca83d70cb..78f872e0a5 100644
--- a/CAP/gap/ReinterpretationOfCategory.gi
+++ b/CAP/gap/ReinterpretationOfCategory.gi
@@ -85,6 +85,7 @@ InstallMethod( ReinterpretationOfCategory,
# the methods for ModelingObject et al. will be installed later once we have a category instance filter
category_constructor_options := rec(
underlying_category_getter_string := "ModelingCategory",
+ underlying_category := C,
underlying_object_getter_string := "ModelingObject",
underlying_morphism_getter_string := "ModelingMorphism",
top_object_getter_string := "ReinterpretationOfObject",
@@ -138,14 +139,6 @@ InstallMethod( ReinterpretationOfCategory,
category_constructor_options.list_of_operations_to_install := list_of_operations_to_install;
- category_constructor_options.operation_weights := rec( );
-
- for operation in list_of_operations_to_install do
-
- category_constructor_options.operation_weights.(operation) := OperationWeight( C, operation );
-
- od;
-
if IsBound( C!.supports_empty_limits ) then
category_constructor_options.supports_empty_limits := C!.supports_empty_limits;
diff --git a/CAP/gap/TerminalCategory.gi b/CAP/gap/TerminalCategory.gi
index 359be26ba3..686d91a689 100644
--- a/CAP/gap/TerminalCategory.gi
+++ b/CAP/gap/TerminalCategory.gi
@@ -24,7 +24,7 @@ BindGlobal( "IsCapTerminalCategoryMorphismRep", IsMorphismInCapTerminalCategoryW
InstallGlobalFunction( CAP_INTERNAL_CONSTRUCTOR_FOR_TERMINAL_CATEGORY,
function( input_record )
- local completed_record, list_of_operations_to_install, skip, info, properties, excluded_properties, T, operation_name;
+ local completed_record, list_of_operations_to_install, skip, info, properties, excluded_properties, T, operation_name, operation;
completed_record := ShallowCopy( input_record );
@@ -104,7 +104,7 @@ InstallGlobalFunction( CAP_INTERNAL_CONSTRUCTOR_FOR_TERMINAL_CATEGORY,
## equality of source and target is part of the specification of the input and checked by the pre-function
return true;
- end );
+ end, 1 );
return T;
@@ -147,13 +147,13 @@ InstallGlobalFunction( TerminalCategoryWithSingleObject, FunctionWithNamedArgume
create_func_object :=
function( name, T )
- return """
+ return Pair( """
function( input_arguments... )
return ObjectConstructor( cat, fail );
end
- """;
+ """, 1 );
end;
@@ -161,13 +161,13 @@ InstallGlobalFunction( TerminalCategoryWithSingleObject, FunctionWithNamedArgume
create_func_morphism :=
function( name, T )
- return """
+ return Pair( """
function( input_arguments... )
return MorphismConstructor( cat, top_source, fail, top_range );
end
- """;
+ """, 1 );
end;
@@ -211,7 +211,7 @@ InstallGlobalFunction( TerminalCategoryWithSingleObject, FunctionWithNamedArgume
return true;
- end );
+ end, 1 );
##
AddIsWellDefinedForMorphisms( T,
@@ -219,7 +219,7 @@ InstallGlobalFunction( TerminalCategoryWithSingleObject, FunctionWithNamedArgume
return true;
- end );
+ end, 1 );
##
AddIsEqualForObjects( T,
@@ -227,7 +227,7 @@ InstallGlobalFunction( TerminalCategoryWithSingleObject, FunctionWithNamedArgume
return true;
- end );
+ end, 1 );
##
AddIsEqualForMorphisms( T,
@@ -235,7 +235,7 @@ InstallGlobalFunction( TerminalCategoryWithSingleObject, FunctionWithNamedArgume
return true;
- end );
+ end, 1 );
##
AddMorphismsOfExternalHom( T,
@@ -243,7 +243,7 @@ InstallGlobalFunction( TerminalCategoryWithSingleObject, FunctionWithNamedArgume
return [ TerminalCategoryWithSingleObjectUniqueMorphism( T ) ];
- end );
+ end, 2 );
if CAP_NAMED_ARGUMENTS.FinalizeCategory then
@@ -321,13 +321,13 @@ InstallGlobalFunction( TerminalCategoryWithMultipleObjects, FunctionWithNamedArg
create_func_object :=
function( name, T )
- return """
+ return Pair( """
function( input_arguments... )
return ObjectConstructor( cat, "operation_name" );
end
- """;
+ """, 1 );
end;
@@ -335,13 +335,13 @@ InstallGlobalFunction( TerminalCategoryWithMultipleObjects, FunctionWithNamedArg
create_func_morphism :=
function( name, T )
- return """
+ return Pair( """
function( input_arguments... )
return MorphismConstructor( cat, top_source, "operation_name", top_range );
end
- """;
+ """, 1 );
end;
@@ -432,7 +432,7 @@ InstallGlobalFunction( TerminalCategoryWithMultipleObjects, FunctionWithNamedArg
return true;
- end );
+ end, 1 );
##
AddSomeIsomorphismBetweenObjects( T,
@@ -440,42 +440,42 @@ InstallGlobalFunction( TerminalCategoryWithMultipleObjects, FunctionWithNamedArg
return MorphismConstructor( T, object_1, "SomeIsomorphismBetweenObjects", object_2 );
- end );
+ end, 1 );
AddDistinguishedObjectOfHomomorphismStructure( T,
function( T )
return TerminalCategoryWithSingleObjectUniqueObject( RangeCategoryOfHomomorphismStructure( T ) );
- end );
+ end, 2 );
AddHomomorphismStructureOnObjects( T,
function( T, source, target )
return TerminalCategoryWithSingleObjectUniqueObject( RangeCategoryOfHomomorphismStructure( T ) );
- end );
+ end, 2 );
AddHomomorphismStructureOnMorphismsWithGivenObjects( T,
function( T, source, morphism_1, morphism_2, target )
return TerminalCategoryWithSingleObjectUniqueMorphism( RangeCategoryOfHomomorphismStructure( T ) );
- end );
+ end, 2 );
AddInterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructureWithGivenObjects( T,
function( T, distinguished_object, morphism, target )
return TerminalCategoryWithSingleObjectUniqueMorphism( RangeCategoryOfHomomorphismStructure( T ) );
- end );
+ end, 2 );
AddInterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism( T,
function( T, source, target, iota )
return MorphismConstructor( T, source, "InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism", target );
- end );
+ end, 1 );
if CAP_NAMED_ARGUMENTS.FinalizeCategory then
diff --git a/CompilerForCAP/tst/300_proof_AdditiveClosure_hom_structure.tst b/CompilerForCAP/tst/300_proof_AdditiveClosure_hom_structure.tst
index e4f3de9218..13d9317ddf 100644
--- a/CompilerForCAP/tst/300_proof_AdditiveClosure_hom_structure.tst
+++ b/CompilerForCAP/tst/300_proof_AdditiveClosure_hom_structure.tst
@@ -33,9 +33,7 @@ gap> dummy_range := DummyCategory( rec(
> properties := [
> "IsAdditiveCategory",
> ],
-> ) : FinalizeCategory := false );;
-gap> AddMorphismBetweenDirectSums( dummy_range, { cat, source_diagram, matrix, target_diagram } -> fail );
-gap> Finalize( dummy_range );;
+> ) );;
#
gap> dummy := DummyCategory( rec(