Skip to content

Commit

Permalink
Merge pull request #1695 from zickgraf/master
Browse files Browse the repository at this point in the history
Further simplifications regarding the derivation mechanism
  • Loading branch information
zickgraf authored Oct 4, 2024
2 parents 6bbb7db + 3c400a7 commit 1cc62b1
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 117 deletions.
2 changes: 1 addition & 1 deletion ActionsForCAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "ActionsForCAP",
Subtitle := "Actions and Coactions for CAP",
Version := "2024.09-01",
Version := "2024.09-02",
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
License := "GPL-2.0-or-later",

Expand Down
26 changes: 10 additions & 16 deletions ActionsForCAP/gap/ActionsCategory.gi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ InstallMethod( LeftActionsCategory,
[ IsCapCategoryObject, IsString, IsList ],

function( acting_object, name, context_filter_list )
local underlying_monoidal_category, preconditions, category_weight_list, i,
local underlying_monoidal_category, preconditions, i,
structure_record, object_constructor, morphism_constructor,
left_actions_category, identity_of_acting_object, tensor_preserves_epis;

Expand Down Expand Up @@ -111,14 +111,11 @@ InstallMethod( LeftActionsCategory,

end;

##
category_weight_list := underlying_monoidal_category!.derivations_weight_list;

## Left action for ZeroObject
preconditions := [ "UniversalMorphismIntoZeroObject",
"TensorProductOnObjects" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

structure_record.ZeroObject :=
function( underlying_zero_object )
Expand All @@ -134,7 +131,7 @@ InstallMethod( LeftActionsCategory,
"DirectSumFunctorialWithGivenDirectSums",
"PreCompose" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

structure_record.DirectSum :=
function( obj_list, underlying_direct_sum )
Expand All @@ -160,7 +157,7 @@ InstallMethod( LeftActionsCategory,
"TensorProductOnObjects", #belongs to TensorProductOnMorphisms
"LiftAlongMonomorphism" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

identity_of_acting_object := IdentityMorphism( acting_object );

Expand Down Expand Up @@ -193,7 +190,7 @@ InstallMethod( LeftActionsCategory,
Add( preconditions, "Colift" );
fi;

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

identity_of_acting_object := IdentityMorphism( acting_object );

Expand Down Expand Up @@ -285,7 +282,7 @@ InstallMethod( RightActionsCategory,
[ IsCapCategoryObject, IsString, IsList ],

function( acting_object, name, context_filter_list )
local underlying_monoidal_category, preconditions, category_weight_list, i,
local underlying_monoidal_category, preconditions, i,
structure_record, object_constructor, morphism_constructor,
right_actions_category, identity_of_acting_object, tensor_preserves_epis;

Expand Down Expand Up @@ -366,14 +363,11 @@ InstallMethod( RightActionsCategory,

end;

##
category_weight_list := underlying_monoidal_category!.derivations_weight_list;

## Right action for ZeroObject
preconditions := [ "UniversalMorphismIntoZeroObject",
"TensorProductOnObjects" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

structure_record.ZeroObject :=
function( underlying_zero_object )
Expand All @@ -389,7 +383,7 @@ InstallMethod( RightActionsCategory,
"DirectSumFunctorialWithGivenDirectSums",
"PreCompose" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

structure_record.DirectSum :=
function( obj_list, underlying_direct_sum )
Expand All @@ -415,7 +409,7 @@ InstallMethod( RightActionsCategory,
"TensorProductOnObjects", #belongs to TensorProductOnMorphisms
"LiftAlongMonomorphism" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

identity_of_acting_object := IdentityMorphism( acting_object );

Expand Down Expand Up @@ -448,7 +442,7 @@ InstallMethod( RightActionsCategory,
Add( preconditions, "Colift" );
fi;

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

identity_of_acting_object := IdentityMorphism( acting_object );

Expand Down
25 changes: 10 additions & 15 deletions ActionsForCAP/gap/CoactionsCategory.gi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ InstallMethod( LeftCoactionsCategory,
[ IsCapCategoryObject, IsString, IsList ],

function( coacting_object, name, context_filter_list )
local underlying_monoidal_category, preconditions, category_weight_list, i,
local underlying_monoidal_category, preconditions, i,
structure_record, object_constructor, morphism_constructor,
left_coactions_category, identity_of_coacting_object;

Expand Down Expand Up @@ -110,14 +110,11 @@ InstallMethod( LeftCoactionsCategory,

end;

##
category_weight_list := underlying_monoidal_category!.derivations_weight_list;

## Left coaction for ZeroObject
preconditions := [ "UniversalMorphismIntoZeroObject",
"TensorProductOnObjects" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

structure_record.ZeroObject :=
function( underlying_zero_object )
Expand All @@ -133,7 +130,7 @@ InstallMethod( LeftCoactionsCategory,
"DirectSumFunctorialWithGivenDirectSums",
"PreCompose" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

structure_record.DirectSum :=
function( obj_list, underlying_direct_sum )
Expand All @@ -160,7 +157,7 @@ InstallMethod( LeftCoactionsCategory,
"TensorProductOnObjects", #belongs to TensorProductOnMorphisms
"Lift" ]; #we can't use LiftAlongMonomorphism here because we don't know if the tensor product is left exact

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

identity_of_coacting_object := IdentityMorphism( coacting_object );

Expand All @@ -185,7 +182,7 @@ InstallMethod( LeftCoactionsCategory,
"TensorProductOnObjects", #belongs to TensorProductOnMorphisms
"ColiftAlongEpimorphism" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

identity_of_coacting_object := IdentityMorphism( coacting_object );

Expand Down Expand Up @@ -263,7 +260,7 @@ InstallMethod( RightCoactionsCategory,
[ IsCapCategoryObject, IsString, IsList ],

function( coacting_object, name, context_filter_list )
local underlying_monoidal_category, preconditions, category_weight_list, i,
local underlying_monoidal_category, preconditions, i,
structure_record, object_constructor, morphism_constructor,
right_coactions_category, identity_of_coacting_object;

Expand Down Expand Up @@ -345,13 +342,11 @@ InstallMethod( RightCoactionsCategory,
end;

##
category_weight_list := underlying_monoidal_category!.derivations_weight_list;

## Right coaction for ZeroObject
preconditions := [ "UniversalMorphismIntoZeroObject",
"TensorProductOnObjects" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

structure_record.ZeroObject :=
function( underlying_zero_object )
Expand All @@ -367,7 +362,7 @@ InstallMethod( RightCoactionsCategory,
"DirectSumFunctorialWithGivenDirectSums",
"PreCompose" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

structure_record.DirectSum :=
function( obj_list, underlying_direct_sum )
Expand All @@ -394,7 +389,7 @@ InstallMethod( RightCoactionsCategory,
"TensorProductOnObjects", #belongs to TensorProductOnMorphisms
"Lift" ]; #we can't use LiftAlongMonomorphism here because we don't know if the tensor product is left exact

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

identity_of_coacting_object := IdentityMorphism( coacting_object );

Expand All @@ -419,7 +414,7 @@ InstallMethod( RightCoactionsCategory,
"TensorProductOnObjects", #belongs to TensorProductOnMorphisms
"ColiftAlongEpimorphism" ];

if ForAll( preconditions, c -> CurrentOperationWeight( category_weight_list, c ) < infinity ) then
if ForAll( preconditions, c -> CanCompute( underlying_monoidal_category, c ) ) then

identity_of_coacting_object := IdentityMorphism( coacting_object );

Expand Down
2 changes: 1 addition & 1 deletion CAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "CAP",
Subtitle := "Categories, Algorithms, Programming",
Version := "2024.09-28",
Version := "2024.09-29",
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
License := "GPL-2.0-or-later",

Expand Down
15 changes: 6 additions & 9 deletions CAP/gap/Derivations.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ DeclareCategory( "IsDerivedMethod", IsAttributeStoringRep );

#! @Description
#! Creates a new derivation object.
#! The argument <A>name</A> is an arbitrary name used to
#! identify this derivation, and is useful only for debugging
#! purposes.
#! The argument <A>target_op_name</A> is the name of the operation which
#! the derived method implements.
#! The argument <A>description</A> should describe the derivation.
#! The argument <A>used_ops_with_multiples</A> contains
#!
#! * the name of each operation used by the derived method,
Expand All @@ -53,23 +51,22 @@ DeclareCategory( "IsDerivedMethod", IsAttributeStoringRep );
#! category for which this derivation will be installed,
#! and return a category for which the operation in the first
#! entry must be installed for the derivation to be considered applicable.
#! The argument <A>func</A> contains the actual implementation of the
#! derived method.
#! The argument <A>weight</A> is an additional number to add
#! when calculating the resulting weight of the target operation
#! using this derivation. Unless there is any particular reason
#! to regard the derivation as exceedingly expensive, this number
#! should be <C>1</C>.
#! The argument <A>func</A> contains the actual implementation of the
#! derived method.
#! The argument <A>category_filter</A> is a filter (or function) describing
#! which categories the derivation is valid for. If it is valid
#! for all categories, then this argument should have the value
#! <C>IsCapCategory</C>. The output of <A>category_filter</A> must not
#! change during the installation of operations. In particular, it must
#! not rely on `CanCompute` to check conditions.
#! @Arguments name, target_op, used_ops_with_multiples, weight, func, category_filter
DeclareOperation( "MakeDerivation",
[ IsString, IsString, IsDenseList,
IsPosInt, IsFunction, IsFunction ] );
#! @Arguments target_op_name, description, used_ops_with_multiples, func, weight, category_filter
DeclareOperation( "CreateDerivation",
[ IsString, IsString, IsDenseList, IsFunction, IsPosInt, IsFunction ] );

#! @Description
#! A description of the derivation.
Expand Down
33 changes: 13 additions & 20 deletions CAP/gap/Derivations.gi
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ InstallGlobalFunction( "DeactivateDerivationInfo",
SetInfoLevel( DerivationInfo, 0 );
end );

InstallMethod( MakeDerivation,
[ IsString, IsString, IsDenseList, IsPosInt, IsFunction, IsFunction ],
InstallMethod( CreateDerivation,
[ IsString, IsString, IsDenseList, IsFunction, IsPosInt, IsFunction ],

function( description, target_op_name, used_op_names_with_multiples_and_category_getters, weight, func, category_filter )
function( target_op_name, description, used_op_names_with_multiples_and_category_getters, func, weight, category_filter )
local wrapped_category_filter, derivation;

#= comment for Julia
Expand Down Expand Up @@ -236,12 +236,14 @@ InstallGlobalFunction( AddDerivation,
fi;
# =#

derivation := MakeDerivation( description,
target_op_name,
used_op_names_with_multiples_and_category_getters,
weight,
func,
category_filter );
derivation := CreateDerivation(
target_op_name,
description,
used_op_names_with_multiples_and_category_getters,
func,
weight,
category_filter
);

if function_called_before_installation <> false then

Expand Down Expand Up @@ -452,7 +454,7 @@ BindGlobal( "TryToInstallDerivation", function ( owl, d )

if new_weight < current_weight or (new_weight = current_weight and current_derivation <> fail and d!.position_in_derivations_by_target < current_derivation!.position_in_derivations_by_target) then

Info( DerivationInfo, 1, Concatenation( "install(",
Info( DerivationInfo, 1, Concatenation( "derive(",
String( new_weight ),
") ",
target,
Expand Down Expand Up @@ -525,18 +527,9 @@ end );
InstallMethod( AddPrimitiveOperation,
[ IsOperationWeightList, IsString, IsInt ],
function( owl, op_name, new_weight )
local current_weight;

Info( DerivationInfo, 1, Concatenation( "install(",
String( new_weight ),
") ",
op_name,
": primitive installation\n" ) );

current_weight := owl!.operation_weights.( op_name );

owl!.operation_weights.( op_name ) := new_weight;
owl!.operation_derivations.( op_name ) := fail;
Assert( 0, owl!.operation_derivations.( op_name ) = fail );

end );

Expand Down
20 changes: 13 additions & 7 deletions CAP/gap/Finalize.gi
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ InstallGlobalFunction( AddFinalDerivationBundle, FunctionWithNamedArguments(
fi;
# =#

Add( derivations, MakeDerivation(
Concatenation( description, " (final derivation)" ),
Add( derivations, CreateDerivation(
NameFunction( current_additional_func[1] ),
Concatenation( description, " (final derivation)" ),
used_op_names_with_multiples_and_category_getters,
weight,
current_additional_func[3],
weight,
category_filter
) );

Expand Down Expand Up @@ -262,12 +262,12 @@ InstallGlobalFunction( AddFinalDerivationBundle, FunctionWithNamedArguments(
fi;

# only used to check if we can install all the derivations in `derivations`
dummy_derivation := MakeDerivation(
"dummy derivation",
dummy_derivation := CreateDerivation(
"internal dummy function of a final derivation",
"dummy derivation",
used_op_names_with_multiples_and_category_getters,
1,
ReturnTrue,
1,
category_filter
);

Expand Down Expand Up @@ -318,6 +318,12 @@ InstallMethod( Finalize,

if weight_list!.operation_weights.(op_name) <> infinity and weight_list!.operation_derivations.(op_name) = fail then

Info( DerivationInfo, 1, Concatenation( "add(",
String( weight_list!.operation_weights.(op_name) ),
") ",
op_name,
": primitive installation\n" ) );

InstallDerivationsUsingOperation( weight_list, op_name );

fi;
Expand Down Expand Up @@ -390,7 +396,7 @@ InstallMethod( Finalize,
# the derivations provided in the bundle.
if new_weight <= current_weight then

Info( DerivationInfo, 1, Concatenation( "install(",
Info( DerivationInfo, 1, Concatenation( "derive(",
String( new_weight ),
") ",
op_name,
Expand Down
Loading

0 comments on commit 1cc62b1

Please sign in to comment.