Skip to content

Commit 9e2064d

Browse files
authored
Merge pull request #704 from zickgraf/MonoidalCategories
Call CAP operations in MonoidalCategories with category as first argument
2 parents 80ad939 + 17711bd commit 9e2064d

20 files changed

+631
-633
lines changed

CAP/PackageInfo.g

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SetPackageInfo( rec(
1010

1111
PackageName := "CAP",
1212
Subtitle := "Categories, Algorithms, Programming",
13-
Version := "2021.08-03",
13+
Version := "2021.08-04",
1414
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
1515
License := "GPL-2.0-or-later",
1616

CAP/gap/CategoryMorphisms.gd

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ DeclareOperation( "PreCompose",
12921292
#! This is a convenience method.
12931293
#! The argument is a list of morphisms
12941294
#! $L = ( \alpha_1: a_1 \rightarrow a_2, \alpha_2: a_2 \rightarrow a_3, \dots, \alpha_n: a_n \rightarrow a_{n+1} )$.
1295-
#! The output is the composition
1295+
#! The output is the composition
12961296
#! $\alpha_{n} \circ ( \alpha_{n-1} \circ ( \dots ( \alpha_2 \circ \alpha_1 ) ) )$.
12971297
#! @Returns a morphism in $\mathrm{Hom}(a_1, a_{n+1})$
12981298
#! @Arguments L
@@ -1318,6 +1318,17 @@ DeclareOperation( "AddPreCompose",
13181318
DeclareOperation( "AddPreCompose",
13191319
[ IsCapCategory, IsList ] );
13201320

1321+
#! @Description
1322+
#! This is a convenience method.
1323+
#! The arguments are a category $C$ and a list of morphisms
1324+
#! $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$.
1325+
#! The output is the composition
1326+
#! $\alpha_{n} \circ ( \alpha_{n-1} \circ ( \dots ( \alpha_2 \circ \alpha_1 ) ) )$.
1327+
#! @Returns a morphism in $\mathrm{Hom}(a_1, a_{n+1})$
1328+
#! @Arguments C, L
1329+
DeclareOperation( "PreComposeList",
1330+
[ IsCapCategory, IsList ] );
1331+
13211332

13221333
#! @Description
13231334
#! The arguments are two morphisms $\beta: b \rightarrow c$, $\alpha: a \rightarrow b$.
@@ -1331,7 +1342,7 @@ DeclareOperation( "PostCompose",
13311342
#! This is a convenience method.
13321343
#! The argument is a list of morphisms
13331344
#! $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 )$.
1334-
#! The output is the composition
1345+
#! The output is the composition
13351346
#! $((\alpha_{n} \circ \alpha_{n-1}) \circ \dots \alpha_2) \circ \alpha_1$.
13361347
#! @Returns a morphism in $\mathrm{Hom}(a_1, a_{n+1})$
13371348
#! @Arguments L
@@ -1357,6 +1368,17 @@ DeclareOperation( "AddPostCompose",
13571368
DeclareOperation( "AddPostCompose",
13581369
[ IsCapCategory, IsList ] );
13591370

1371+
#! @Description
1372+
#! This is a convenience method.
1373+
#! The arguments are a category $C$ and a list of morphisms
1374+
#! $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 )$.
1375+
#! The output is the composition
1376+
#! $((\alpha_{n} \circ \alpha_{n-1}) \circ \dots \alpha_2) \circ \alpha_1$.
1377+
#! @Returns a morphism in $\mathrm{Hom}(a_1, a_{n+1})$
1378+
#! @Arguments C, L
1379+
DeclareOperation( "PostComposeList",
1380+
[ IsCapCategory, IsList ] );
1381+
13601382

13611383
###################################
13621384
##

CAP/gap/CategoryMorphisms.gi

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -475,25 +475,24 @@ InstallMethod( PreCompose,
475475
[ IsList ],
476476

477477
function( morphism_list )
478-
local length, result_morphism, i;
479478

480-
length := Length( morphism_list );
481-
482-
if length = 0 then
483-
484-
Error( "non-empty list expected" );
485-
479+
if IsEmpty( morphism_list ) then
480+
481+
Error( "non-empty list expected" );
482+
486483
fi;
487484

488-
result_morphism := morphism_list[1];
485+
return PreComposeList( CapCategory( morphism_list[1] ), morphism_list );
489486

490-
for i in [ 2 .. length ] do
491-
492-
result_morphism := PreCompose( result_morphism, morphism_list[i] );
493-
494-
od;
487+
end );
488+
489+
##
490+
InstallMethodForCompilerForCAP( PreComposeList,
491+
[ IsCapCategory, IsList ],
492+
493+
function( cat, morphism_list )
495494

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

498497
end );
499498

@@ -502,25 +501,24 @@ InstallMethod( PostCompose,
502501
[ IsList ],
503502

504503
function( morphism_list )
505-
local length, result_morphism, i;
506504

507-
length := Length( morphism_list );
508-
509-
if length = 0 then
510-
511-
Error( "non-empty list expected" );
512-
505+
if IsEmpty( morphism_list ) then
506+
507+
Error( "non-empty list expected" );
508+
513509
fi;
514510

515-
result_morphism := morphism_list[1];
511+
return PostComposeList( CapCategory( morphism_list[1] ), morphism_list );
516512

517-
for i in [ 2 .. length ] do
518-
519-
result_morphism := PostCompose( result_morphism, morphism_list[i] );
520-
521-
od;
513+
end );
514+
515+
##
516+
InstallMethodForCompilerForCAP( PostComposeList,
517+
[ IsCapCategory, IsList ],
518+
519+
function( cat, morphism_list )
522520

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

525523
end );
526524

MonoidalCategories/PackageInfo.g

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ SetPackageInfo( rec(
1010

1111
PackageName := "MonoidalCategories",
1212
Subtitle := "Monoidal and monoidal (co)closed categories",
13-
Version := "2021.08-01",
14-
13+
Version := "2021.08-02",
1514
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
1615
License := "GPL-2.0-or-later",
1716

@@ -120,7 +119,7 @@ Dependencies := rec(
120119
NeededOtherPackages := [
121120
[ "GAPDoc", ">= 1.5" ],
122121
[ "ToolsForHomalg", ">= 2018.05.22" ],
123-
[ "CAP", ">= 2021.08-03" ],
122+
[ "CAP", ">= 2021.08-04" ],
124123
],
125124
SuggestedOtherPackages := [ ],
126125
ExternalConditions := [ ],

MonoidalCategories/gap/AdditiveMonoidalCategories.gi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ AddDerivationToCAP( LeftDistributivityExpanding,
44
function( cat, object, summands_list )
55
local source_and_range;
66

7-
source_and_range := TensorProductOnObjects( object, DirectSum( summands_list ) );
7+
source_and_range := TensorProductOnObjects( cat, object, DirectSum( cat, summands_list ) );
88

9-
return LeftDistributivityExpandingWithGivenObjects(
9+
return LeftDistributivityExpandingWithGivenObjects( cat,
1010
source_and_range,
1111
object, summands_list,
1212
source_and_range
@@ -21,9 +21,9 @@ AddDerivationToCAP( LeftDistributivityFactoring,
2121
function( cat, object, summands_list )
2222
local source_and_range;
2323

24-
source_and_range := TensorProductOnObjects( object, DirectSum( summands_list ) );
24+
source_and_range := TensorProductOnObjects( cat, object, DirectSum( cat, summands_list ) );
2525

26-
return LeftDistributivityFactoringWithGivenObjects(
26+
return LeftDistributivityFactoringWithGivenObjects( cat,
2727
source_and_range,
2828
object, summands_list,
2929
source_and_range
@@ -38,9 +38,9 @@ AddDerivationToCAP( RightDistributivityExpanding,
3838
function( cat, summands_list, object )
3939
local source_and_range;
4040

41-
source_and_range := TensorProductOnObjects( DirectSum( summands_list ), object );
41+
source_and_range := TensorProductOnObjects( cat, DirectSum( cat, summands_list ), object );
4242

43-
return RightDistributivityExpandingWithGivenObjects(
43+
return RightDistributivityExpandingWithGivenObjects( cat,
4444
source_and_range,
4545
summands_list, object,
4646
source_and_range
@@ -55,9 +55,9 @@ AddDerivationToCAP( RightDistributivityFactoring,
5555
function( cat, summands_list, object )
5656
local source_and_range;
5757

58-
source_and_range := TensorProductOnObjects( DirectSum( summands_list ), object );
58+
source_and_range := TensorProductOnObjects( cat, DirectSum( cat, summands_list ), object );
5959

60-
return RightDistributivityFactoringWithGivenObjects(
60+
return RightDistributivityFactoringWithGivenObjects( cat,
6161
source_and_range,
6262
summands_list, object,
6363
source_and_range

MonoidalCategories/gap/AdditiveMonoidalCategoriesDerivedMethods.gi

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ AddDerivationToCAP( LeftDistributivityExpandingWithGivenObjects,
66

77
nr_summands := Size( summands );
88

9-
id := IdentityMorphism( object );
9+
id := IdentityMorphism( cat, object );
1010

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

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

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

17-
return UniversalMorphismIntoDirectSum( diagram, projection_list );
17+
return UniversalMorphismIntoDirectSum( cat, diagram, projection_list );
1818

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

2828
nr_summands := Size( summands );
2929

30-
id := IdentityMorphism( object );
30+
id := IdentityMorphism( cat, object );
3131

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

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

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

38-
return UniversalMorphismFromDirectSum( diagram, injection_list );
38+
return UniversalMorphismFromDirectSum( cat, diagram, injection_list );
3939

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

4949
nr_summands := Size( summands );
5050

51-
id := IdentityMorphism( object );
51+
id := IdentityMorphism( cat, object );
5252

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

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

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

59-
return UniversalMorphismIntoDirectSum( diagram, projection_list );
59+
return UniversalMorphismIntoDirectSum( cat, diagram, projection_list );
6060

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

7070
nr_summands := Size( summands );
7171

72-
id := IdentityMorphism( object );
72+
id := IdentityMorphism( cat, object );
7373

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

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

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

80-
return UniversalMorphismFromDirectSum( diagram, injection_list );
80+
return UniversalMorphismFromDirectSum( cat, diagram, injection_list );
8181

8282
end : CategoryFilter := IsMonoidalCategory and IsAdditiveCategory,
8383
Description := "RightDistributivityFactoringWithGivenObjects using the universal property of the direct sum" );

MonoidalCategories/gap/BraidedMonoidalCategories.gi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ AddDerivationToCAP( Braiding,
44
function( cat, object_1, object_2 )
55
local source_and_range;
66

7-
source_and_range := TensorProductOnObjects( object_1, object_2 );
7+
source_and_range := TensorProductOnObjects( cat, object_1, object_2 );
88

9-
return BraidingWithGivenTensorProducts( source_and_range, object_1, object_2, source_and_range );
9+
return BraidingWithGivenTensorProducts( cat, source_and_range, object_1, object_2, source_and_range );
1010

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

20-
source_and_range := TensorProductOnObjects( object_1, object_2 );
20+
source_and_range := TensorProductOnObjects( cat, object_1, object_2 );
2121

22-
return BraidingInverseWithGivenTensorProducts( source_and_range, object_1, object_2, source_and_range );
22+
return BraidingInverseWithGivenTensorProducts( cat, source_and_range, object_1, object_2, source_and_range );
2323

2424
end : CategoryFilter := IsSkeletalCategory,
2525
Description := "calling the WithGiven operation in a skeletal setting" );

MonoidalCategories/gap/BraidedMonoidalCategoriesDerivedMethods.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ AddDerivationToCAP( BraidingInverseWithGivenTensorProducts,
33

44
function( cat, object_2_tensored_object_1, object_1, object_2, object_1_tensored_object_2 )
55
##TODO: Use BraidingWithGiven
6-
return Inverse( Braiding( object_1, object_2 ) );
6+
return InverseForMorphisms( cat, Braiding( cat, object_1, object_2 ) );
77

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

1414
function( cat, object_1_tensored_object_2, object_1, object_2, object_2_tensored_object_1 )
1515
##TODO: Use BraidingInverseWithGiven
16-
return Inverse( BraidingInverse( object_1, object_2 ) );
16+
return InverseForMorphisms( cat, BraidingInverse( cat, object_1, object_2 ) );
1717

1818
end : CategoryFilter := IsBraidedMonoidalCategory,
1919
Description := "BraidingWithGivenTensorProducts as the inverse of BraidingInverse" );

MonoidalCategories/gap/BraidedMonoidalCategoriesMethodRecord.gi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ InstallValue( BRAIDED_MONOIDAL_CATEGORIES_METHOD_NAME_RECORD, rec(
33
Braiding := rec(
44
filter_list := [ "category", "object", "object" ],
55
io_type := [ [ "a", "b" ], [ "s", "r" ] ],
6-
output_source_getter_string := "TensorProductOnObjects( a, b )",
7-
output_range_getter_string := "TensorProductOnObjects( b, a )",
6+
output_source_getter_string := "TensorProductOnObjects( cat, a, b )",
7+
output_range_getter_string := "TensorProductOnObjects( cat, b, a )",
88
with_given_object_position := "both",
99
return_type := "morphism" ),
1010

@@ -16,8 +16,8 @@ BraidingWithGivenTensorProducts := rec(
1616
BraidingInverse := rec(
1717
filter_list := [ "category", "object", "object" ],
1818
io_type := [ [ "a", "b" ], [ "s", "r" ] ],
19-
output_source_getter_string := "TensorProductOnObjects( b, a )",
20-
output_range_getter_string := "TensorProductOnObjects( a, b )",
19+
output_source_getter_string := "TensorProductOnObjects( cat, b, a )",
20+
output_range_getter_string := "TensorProductOnObjects( cat, a, b )",
2121
with_given_object_position := "both",
2222
return_type := "morphism" ),
2323

MonoidalCategories/gap/ClosedMonoidalCategories.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ AddDerivationToCAP( IsomorphismFromInternalHomToObject,
33

44
function( cat, object )
55

6-
return IsomorphismFromInternalHomToObjectWithGivenInternalHom( object, object );
6+
return IsomorphismFromInternalHomToObjectWithGivenInternalHom( cat, object, object );
77

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

1414
function( cat, object )
1515

16-
return IsomorphismFromObjectToInternalHomWithGivenInternalHom( object, object );
16+
return IsomorphismFromObjectToInternalHomWithGivenInternalHom( cat, object, object );
1717

1818
end : CategoryFilter := IsSkeletalCategory,
1919
Description := "calling the WithGiven operation in a skeletal setting" );

MonoidalCategories/gap/ClosedMonoidalCategoriesDerivedMethods.gi

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ AddFinalDerivation( IsomorphismFromDualToInternalHom,
1818
MorphismFromTensorProductToInternalHomWithGivenObjects ],
1919

2020
function( cat, object )
21-
local category;
2221

23-
category := CapCategory( object );
24-
25-
return IdentityMorphism( InternalHomOnObjects( object, TensorUnit( category ) ) );
22+
return IdentityMorphism( cat, InternalHomOnObjects( cat, object, TensorUnit( cat ) ) );
2623

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

4441
function( cat, object )
45-
local category;
46-
47-
category := CapCategory( object );
4842

49-
return IdentityMorphism( InternalHomOnObjects( object, TensorUnit( category ) ) );
43+
return IdentityMorphism( cat, InternalHomOnObjects( cat, object, TensorUnit( cat ) ) );
5044

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

0 commit comments

Comments
 (0)