Skip to content

Commit

Permalink
Merge pull request #704 from zickgraf/MonoidalCategories
Browse files Browse the repository at this point in the history
Call CAP operations in MonoidalCategories with category as first argument
  • Loading branch information
zickgraf authored Sep 1, 2021
2 parents 80ad939 + 17711bd commit 9e2064d
Show file tree
Hide file tree
Showing 20 changed files with 631 additions and 633 deletions.
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 := "2021.08-03",
Version := "2021.08-04",
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
License := "GPL-2.0-or-later",

Expand Down
26 changes: 24 additions & 2 deletions CAP/gap/CategoryMorphisms.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ DeclareOperation( "PreCompose",
#! This is a convenience method.
#! The argument is a list of morphisms
#! $L = ( \alpha_1: a_1 \rightarrow a_2, \alpha_2: a_2 \rightarrow a_3, \dots, \alpha_n: a_n \rightarrow a_{n+1} )$.
#! The output is the composition
#! The output is the composition
#! $\alpha_{n} \circ ( \alpha_{n-1} \circ ( \dots ( \alpha_2 \circ \alpha_1 ) ) )$.
#! @Returns a morphism in $\mathrm{Hom}(a_1, a_{n+1})$
#! @Arguments L
Expand All @@ -1318,6 +1318,17 @@ DeclareOperation( "AddPreCompose",
DeclareOperation( "AddPreCompose",
[ IsCapCategory, IsList ] );

#! @Description
#! This is a convenience method.
#! The arguments are a category $C$ and a list of morphisms
#! $L = ( \alpha_1: a_1 \rightarrow a_2, \alpha_2: a_2 \rightarrow a_3, \dots, \alpha_n: a_n \rightarrow a_{n+1} )$ in $C$.
#! The output is the composition
#! $\alpha_{n} \circ ( \alpha_{n-1} \circ ( \dots ( \alpha_2 \circ \alpha_1 ) ) )$.
#! @Returns a morphism in $\mathrm{Hom}(a_1, a_{n+1})$
#! @Arguments C, L
DeclareOperation( "PreComposeList",
[ IsCapCategory, IsList ] );


#! @Description
#! The arguments are two morphisms $\beta: b \rightarrow c$, $\alpha: a \rightarrow b$.
Expand All @@ -1331,7 +1342,7 @@ DeclareOperation( "PostCompose",
#! This is a convenience method.
#! The argument is a list of morphisms
#! $L = ( \alpha_n: a_n \rightarrow a_{n+1}, \alpha_{n-1}: a_{n-1} \rightarrow a_n, \dots, \alpha_1: a_1 \rightarrow a_2 )$.
#! The output is the composition
#! The output is the composition
#! $((\alpha_{n} \circ \alpha_{n-1}) \circ \dots \alpha_2) \circ \alpha_1$.
#! @Returns a morphism in $\mathrm{Hom}(a_1, a_{n+1})$
#! @Arguments L
Expand All @@ -1357,6 +1368,17 @@ DeclareOperation( "AddPostCompose",
DeclareOperation( "AddPostCompose",
[ IsCapCategory, IsList ] );

#! @Description
#! This is a convenience method.
#! The arguments are a category $C$ and a list of morphisms
#! $L = ( \alpha_n: a_n \rightarrow a_{n+1}, \alpha_{n-1}: a_{n-1} \rightarrow a_n, \dots, \alpha_1: a_1 \rightarrow a_2 )$.
#! The output is the composition
#! $((\alpha_{n} \circ \alpha_{n-1}) \circ \dots \alpha_2) \circ \alpha_1$.
#! @Returns a morphism in $\mathrm{Hom}(a_1, a_{n+1})$
#! @Arguments C, L
DeclareOperation( "PostComposeList",
[ IsCapCategory, IsList ] );


###################################
##
Expand Down
54 changes: 26 additions & 28 deletions CAP/gap/CategoryMorphisms.gi
Original file line number Diff line number Diff line change
Expand Up @@ -475,25 +475,24 @@ InstallMethod( PreCompose,
[ IsList ],

function( morphism_list )
local length, result_morphism, i;

length := Length( morphism_list );

if length = 0 then

Error( "non-empty list expected" );

if IsEmpty( morphism_list ) then

Error( "non-empty list expected" );

fi;

result_morphism := morphism_list[1];
return PreComposeList( CapCategory( morphism_list[1] ), morphism_list );

for i in [ 2 .. length ] do

result_morphism := PreCompose( result_morphism, morphism_list[i] );

od;
end );

##
InstallMethodForCompilerForCAP( PreComposeList,
[ IsCapCategory, IsList ],

function( cat, morphism_list )

return result_morphism;
return Iterated( morphism_list, { alpha, beta } -> PreCompose( cat, alpha, beta ) );

end );

Expand All @@ -502,25 +501,24 @@ InstallMethod( PostCompose,
[ IsList ],

function( morphism_list )
local length, result_morphism, i;

length := Length( morphism_list );

if length = 0 then

Error( "non-empty list expected" );

if IsEmpty( morphism_list ) then

Error( "non-empty list expected" );

fi;

result_morphism := morphism_list[1];
return PostComposeList( CapCategory( morphism_list[1] ), morphism_list );

for i in [ 2 .. length ] do

result_morphism := PostCompose( result_morphism, morphism_list[i] );

od;
end );

##
InstallMethodForCompilerForCAP( PostComposeList,
[ IsCapCategory, IsList ],

function( cat, morphism_list )

return result_morphism;
return Iterated( morphism_list, { beta, alpha } -> PostCompose( cat, beta, alpha ) );

end );

Expand Down
5 changes: 2 additions & 3 deletions MonoidalCategories/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ SetPackageInfo( rec(

PackageName := "MonoidalCategories",
Subtitle := "Monoidal and monoidal (co)closed categories",
Version := "2021.08-01",

Version := "2021.08-02",
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
License := "GPL-2.0-or-later",

Expand Down Expand Up @@ -120,7 +119,7 @@ Dependencies := rec(
NeededOtherPackages := [
[ "GAPDoc", ">= 1.5" ],
[ "ToolsForHomalg", ">= 2018.05.22" ],
[ "CAP", ">= 2021.08-03" ],
[ "CAP", ">= 2021.08-04" ],
],
SuggestedOtherPackages := [ ],
ExternalConditions := [ ],
Expand Down
16 changes: 8 additions & 8 deletions MonoidalCategories/gap/AdditiveMonoidalCategories.gi
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ AddDerivationToCAP( LeftDistributivityExpanding,
function( cat, object, summands_list )
local source_and_range;

source_and_range := TensorProductOnObjects( object, DirectSum( summands_list ) );
source_and_range := TensorProductOnObjects( cat, object, DirectSum( cat, summands_list ) );

return LeftDistributivityExpandingWithGivenObjects(
return LeftDistributivityExpandingWithGivenObjects( cat,
source_and_range,
object, summands_list,
source_and_range
Expand All @@ -21,9 +21,9 @@ AddDerivationToCAP( LeftDistributivityFactoring,
function( cat, object, summands_list )
local source_and_range;

source_and_range := TensorProductOnObjects( object, DirectSum( summands_list ) );
source_and_range := TensorProductOnObjects( cat, object, DirectSum( cat, summands_list ) );

return LeftDistributivityFactoringWithGivenObjects(
return LeftDistributivityFactoringWithGivenObjects( cat,
source_and_range,
object, summands_list,
source_and_range
Expand All @@ -38,9 +38,9 @@ AddDerivationToCAP( RightDistributivityExpanding,
function( cat, summands_list, object )
local source_and_range;

source_and_range := TensorProductOnObjects( DirectSum( summands_list ), object );
source_and_range := TensorProductOnObjects( cat, DirectSum( cat, summands_list ), object );

return RightDistributivityExpandingWithGivenObjects(
return RightDistributivityExpandingWithGivenObjects( cat,
source_and_range,
summands_list, object,
source_and_range
Expand All @@ -55,9 +55,9 @@ AddDerivationToCAP( RightDistributivityFactoring,
function( cat, summands_list, object )
local source_and_range;

source_and_range := TensorProductOnObjects( DirectSum( summands_list ), object );
source_and_range := TensorProductOnObjects( cat, DirectSum( cat, summands_list ), object );

return RightDistributivityFactoringWithGivenObjects(
return RightDistributivityFactoringWithGivenObjects( cat,
source_and_range,
summands_list, object,
source_and_range
Expand Down
40 changes: 20 additions & 20 deletions MonoidalCategories/gap/AdditiveMonoidalCategoriesDerivedMethods.gi
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ AddDerivationToCAP( LeftDistributivityExpandingWithGivenObjects,

nr_summands := Size( summands );

id := IdentityMorphism( object );
id := IdentityMorphism( cat, object );

projection_list := List( [ 1 .. nr_summands ], i -> ProjectionInFactorOfDirectSum( summands, i ) );
projection_list := List( [ 1 .. nr_summands ], i -> ProjectionInFactorOfDirectSum( cat, summands, i ) );

projection_list := List( projection_list, mor -> TensorProductOnMorphisms( id, mor ) );
projection_list := List( projection_list, mor -> TensorProductOnMorphisms( cat, id, mor ) );

diagram := List( summands, summand -> TensorProductOnObjects( object, summand ) );
diagram := List( summands, summand -> TensorProductOnObjects( cat, object, summand ) );

return UniversalMorphismIntoDirectSum( diagram, projection_list );
return UniversalMorphismIntoDirectSum( cat, diagram, projection_list );

end : CategoryFilter := IsMonoidalCategory and IsAdditiveCategory,
Description := "LeftDistributivityExpandingWithGivenObjects using the universal property of the direct sum" );
Expand All @@ -27,15 +27,15 @@ AddDerivationToCAP( LeftDistributivityFactoringWithGivenObjects,

nr_summands := Size( summands );

id := IdentityMorphism( object );
id := IdentityMorphism( cat, object );

injection_list := List( [ 1 .. nr_summands ], i -> InjectionOfCofactorOfDirectSum( summands, i ) );
injection_list := List( [ 1 .. nr_summands ], i -> InjectionOfCofactorOfDirectSum( cat, summands, i ) );

injection_list := List( injection_list, mor -> TensorProductOnMorphisms( id, mor ) );
injection_list := List( injection_list, mor -> TensorProductOnMorphisms( cat, id, mor ) );

diagram := List( summands, summand -> TensorProductOnObjects( object, summand ) );
diagram := List( summands, summand -> TensorProductOnObjects( cat, object, summand ) );

return UniversalMorphismFromDirectSum( diagram, injection_list );
return UniversalMorphismFromDirectSum( cat, diagram, injection_list );

end : CategoryFilter := IsMonoidalCategory and IsAdditiveCategory,
Description := "LeftDistributivityFactoringWithGivenObjects using the universal property of the direct sum" );
Expand All @@ -48,15 +48,15 @@ AddDerivationToCAP( RightDistributivityExpandingWithGivenObjects,

nr_summands := Size( summands );

id := IdentityMorphism( object );
id := IdentityMorphism( cat, object );

projection_list := List( [ 1 .. nr_summands ], i -> ProjectionInFactorOfDirectSum( summands, i ) );
projection_list := List( [ 1 .. nr_summands ], i -> ProjectionInFactorOfDirectSum( cat, summands, i ) );

projection_list := List( projection_list, mor -> TensorProductOnMorphisms( mor, id ) );
projection_list := List( projection_list, mor -> TensorProductOnMorphisms( cat, mor, id ) );

diagram := List( summands, summand -> TensorProductOnObjects( summand, object ) );
diagram := List( summands, summand -> TensorProductOnObjects( cat, summand, object ) );

return UniversalMorphismIntoDirectSum( diagram, projection_list );
return UniversalMorphismIntoDirectSum( cat, diagram, projection_list );

end : CategoryFilter := IsMonoidalCategory and IsAdditiveCategory,
Description := "RightDistributivityExpandingWithGivenObjects using the universal property of the direct sum" );
Expand All @@ -69,15 +69,15 @@ AddDerivationToCAP( RightDistributivityFactoringWithGivenObjects,

nr_summands := Size( summands );

id := IdentityMorphism( object );
id := IdentityMorphism( cat, object );

injection_list := List( [ 1 .. nr_summands ], i -> InjectionOfCofactorOfDirectSum( summands, i ) );
injection_list := List( [ 1 .. nr_summands ], i -> InjectionOfCofactorOfDirectSum( cat, summands, i ) );

injection_list := List( injection_list, mor -> TensorProductOnMorphisms( mor, id ) );
injection_list := List( injection_list, mor -> TensorProductOnMorphisms( cat, mor, id ) );

diagram := List( summands, summand -> TensorProductOnObjects( summand, object ) );
diagram := List( summands, summand -> TensorProductOnObjects( cat, summand, object ) );

return UniversalMorphismFromDirectSum( diagram, injection_list );
return UniversalMorphismFromDirectSum( cat, diagram, injection_list );

end : CategoryFilter := IsMonoidalCategory and IsAdditiveCategory,
Description := "RightDistributivityFactoringWithGivenObjects using the universal property of the direct sum" );
8 changes: 4 additions & 4 deletions MonoidalCategories/gap/BraidedMonoidalCategories.gi
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ AddDerivationToCAP( Braiding,
function( cat, object_1, object_2 )
local source_and_range;

source_and_range := TensorProductOnObjects( object_1, object_2 );
source_and_range := TensorProductOnObjects( cat, object_1, object_2 );

return BraidingWithGivenTensorProducts( source_and_range, object_1, object_2, source_and_range );
return BraidingWithGivenTensorProducts( cat, source_and_range, object_1, object_2, source_and_range );

end : CategoryFilter := IsSkeletalCategory,
Description := "calling the WithGiven operation in a skeletal setting" );
Expand All @@ -17,9 +17,9 @@ AddDerivationToCAP( BraidingInverse,
function( cat, object_1, object_2 )
local source_and_range;

source_and_range := TensorProductOnObjects( object_1, object_2 );
source_and_range := TensorProductOnObjects( cat, object_1, object_2 );

return BraidingInverseWithGivenTensorProducts( source_and_range, object_1, object_2, source_and_range );
return BraidingInverseWithGivenTensorProducts( cat, source_and_range, object_1, object_2, source_and_range );

end : CategoryFilter := IsSkeletalCategory,
Description := "calling the WithGiven operation in a skeletal setting" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AddDerivationToCAP( BraidingInverseWithGivenTensorProducts,

function( cat, object_2_tensored_object_1, object_1, object_2, object_1_tensored_object_2 )
##TODO: Use BraidingWithGiven
return Inverse( Braiding( object_1, object_2 ) );
return InverseForMorphisms( cat, Braiding( cat, object_1, object_2 ) );

end : CategoryFilter := IsBraidedMonoidalCategory,
Description := "BraidingInverseWithGivenTensorProducts as the inverse of the braiding" );
Expand All @@ -13,7 +13,7 @@ AddDerivationToCAP( BraidingWithGivenTensorProducts,

function( cat, object_1_tensored_object_2, object_1, object_2, object_2_tensored_object_1 )
##TODO: Use BraidingInverseWithGiven
return Inverse( BraidingInverse( object_1, object_2 ) );
return InverseForMorphisms( cat, BraidingInverse( cat, object_1, object_2 ) );

end : CategoryFilter := IsBraidedMonoidalCategory,
Description := "BraidingWithGivenTensorProducts as the inverse of BraidingInverse" );
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ InstallValue( BRAIDED_MONOIDAL_CATEGORIES_METHOD_NAME_RECORD, rec(
Braiding := rec(
filter_list := [ "category", "object", "object" ],
io_type := [ [ "a", "b" ], [ "s", "r" ] ],
output_source_getter_string := "TensorProductOnObjects( a, b )",
output_range_getter_string := "TensorProductOnObjects( b, a )",
output_source_getter_string := "TensorProductOnObjects( cat, a, b )",
output_range_getter_string := "TensorProductOnObjects( cat, b, a )",
with_given_object_position := "both",
return_type := "morphism" ),

Expand All @@ -16,8 +16,8 @@ BraidingWithGivenTensorProducts := rec(
BraidingInverse := rec(
filter_list := [ "category", "object", "object" ],
io_type := [ [ "a", "b" ], [ "s", "r" ] ],
output_source_getter_string := "TensorProductOnObjects( b, a )",
output_range_getter_string := "TensorProductOnObjects( a, b )",
output_source_getter_string := "TensorProductOnObjects( cat, b, a )",
output_range_getter_string := "TensorProductOnObjects( cat, a, b )",
with_given_object_position := "both",
return_type := "morphism" ),

Expand Down
4 changes: 2 additions & 2 deletions MonoidalCategories/gap/ClosedMonoidalCategories.gi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AddDerivationToCAP( IsomorphismFromInternalHomToObject,

function( cat, object )

return IsomorphismFromInternalHomToObjectWithGivenInternalHom( object, object );
return IsomorphismFromInternalHomToObjectWithGivenInternalHom( cat, object, object );

end : CategoryFilter := IsSkeletalCategory,
Description := "calling the WithGiven operation in a skeletal setting" );
Expand All @@ -13,7 +13,7 @@ AddDerivationToCAP( IsomorphismFromObjectToInternalHom,

function( cat, object )

return IsomorphismFromObjectToInternalHomWithGivenInternalHom( object, object );
return IsomorphismFromObjectToInternalHomWithGivenInternalHom( cat, object, object );

end : CategoryFilter := IsSkeletalCategory,
Description := "calling the WithGiven operation in a skeletal setting" );
Expand Down
10 changes: 2 additions & 8 deletions MonoidalCategories/gap/ClosedMonoidalCategoriesDerivedMethods.gi
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ AddFinalDerivation( IsomorphismFromDualToInternalHom,
MorphismFromTensorProductToInternalHomWithGivenObjects ],

function( cat, object )
local category;

category := CapCategory( object );

return IdentityMorphism( InternalHomOnObjects( object, TensorUnit( category ) ) );
return IdentityMorphism( cat, InternalHomOnObjects( cat, object, TensorUnit( cat ) ) );

end : CategoryFilter := IsClosedMonoidalCategory,
Description := "IsomorphismFromDualToInternalHom as the identity of Hom(a,1)" );
Expand All @@ -42,11 +39,8 @@ AddFinalDerivation( IsomorphismFromInternalHomToDual,
MorphismFromTensorProductToInternalHomWithGivenObjects ],

function( cat, object )
local category;

category := CapCategory( object );

return IdentityMorphism( InternalHomOnObjects( object, TensorUnit( category ) ) );
return IdentityMorphism( cat, InternalHomOnObjects( cat, object, TensorUnit( cat ) ) );

end : CategoryFilter := IsClosedMonoidalCategory,
Description := "IsomorphismFromInternalHomToDual as the identity of Hom(a,1)" );
Loading

0 comments on commit 9e2064d

Please sign in to comment.