Skip to content

Commit 79ca48a

Browse files
committed
Move the homomorphism structure into a separate file
which is only loaded when FinSets is available. Otherwise there are call to methods from FinSets, which is not loaded in the CAP_project-CI. This results in warnings such as: Syntax warning: Unbound global variable MapOfFinSets Syntax warning: Unbound global variable GROUPS_AS_CATEGORIES_SkeletalFinSets
1 parent 3fec970 commit 79ca48a

6 files changed

Lines changed: 159 additions & 110 deletions

File tree

GroupsAsCategoriesForCAP/PackageInfo.g

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

1111
PackageName := "GroupsAsCategoriesForCAP",
1212
Subtitle := "Groups as categories on one object",
13-
Version := "2025.06-01",
13+
Version := "2025.06-02",
1414
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)( ),
1515
License := "GPL-2.0-or-later",
1616

@@ -91,6 +91,13 @@ Dependencies := rec(
9191
ExternalConditions := [ ],
9292
),
9393

94+
Extensions := [
95+
rec(
96+
needed := [ [ "FinSetsForCAP", ">= 2023.07-03" ] ],
97+
filename := "gap/HomomorphismStructure.gi",
98+
),
99+
],
100+
94101
AvailabilityTest := function()
95102
return true;
96103
end,

GroupsAsCategoriesForCAP/examples/GroupsAsCats.g

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
LoadPackage( "GroupsAsCategoriesForCAP" );;
44

55
#! @Example
6-
#! #@if IsPackageMarkedForLoading( "FinSetsForCAP", ">= 2023.07-03" )
76
G := SymmetricGroup( 3 );;
87
CG := GroupAsCategory( G );;
98
u := GroupAsCategoryUniqueObject( CG );;
109
SetOfObjectsOfCategory( CG ) = [ u ];
1110
#! true
1211
Length( SetOfMorphismsOfFiniteCategory( CG ) ) = Size( G );
1312
#! true
13+
x := (2,3)/CG;;
14+
id := ()/CG;;
15+
IsIdenticalObj( x * x, id );
16+
#! true
1417
alpha := GroupAsCategoryMorphism( (1,2,3), CG );;
1518
alpha * Inverse( alpha ) = IdentityMorphism( u );
1619
#! true
@@ -24,6 +27,7 @@ Lift( alpha, gamma ) * gamma = alpha;
2427
#! true
2528
alpha * Colift( alpha, gamma ) = gamma;
2629
#! true
30+
#! #@if IsPackageMarkedForLoading( "FinSetsForCAP", ">= 2023.07-03" )
2731
Length( HomomorphismStructureOnObjects( u, u ) ) = Size( G );
2832
#! true
2933
InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism(
@@ -35,9 +39,5 @@ InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism(
3539
=
3640
gamma * alpha * Inverse( gamma );
3741
#! true
38-
x := (2,3)/CG;;
39-
id := ()/CG;;
40-
IsIdenticalObj( x * x, id );
41-
#! true
4242
#! #@fi
4343
#! @EndExample

GroupsAsCategoriesForCAP/gap/GroupsAsCats.gi

Lines changed: 9 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@
1010
##
1111
####################################
1212

13-
if IsPackageMarkedForLoading( "FinSetsForCAP", ">= 2023.07-03" ) then
14-
15-
BindGlobal( "GROUPS_AS_CATEGORIES_SkeletalFinSets", SkeletalCategoryOfFiniteSets( : overhead := false ) );
16-
17-
fi;
18-
1913
##
2014
InstallMethod( GroupAsCategory,
2115
[ IsGroup ],
2216

2317
function( group )
2418
local category, is_finite;
2519

26-
category := CreateCapCategory( Concatenation( "Group as category( ", String( group )," )" ), IsGroupAsCategory, IsGroupAsCategoryObject, IsGroupAsCategoryMorphism, IsCapCategoryTwoCell : overhead := false );
20+
category := CreateCapCategory( Concatenation( "Group as category( ", String( group )," )" ),
21+
IsGroupAsCategory,
22+
IsGroupAsCategoryObject,
23+
IsGroupAsCategoryMorphism,
24+
IsCapCategoryTwoCell
25+
: overhead := false );
2726

2827
category!.compiler_hints := rec(
2928
category_attribute_names := [
@@ -43,8 +42,7 @@ InstallMethod( GroupAsCategory,
4342

4443
if IsPackageMarkedForLoading( "FinSetsForCAP", ">= 2023.07-03" ) then
4544

46-
SetRangeCategoryOfHomomorphismStructure( category, GROUPS_AS_CATEGORIES_SkeletalFinSets );
47-
SetIsEquippedWithHomomorphismStructure( category, true );
45+
SET_HOMOMORPHISM_STRUCTURE_ATTRIBUTES_FOR_GROUP_AS_CATEGORY( category );
4846

4947
fi;
5048

@@ -270,103 +268,10 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_GROUP_AS_CATEGORY,
270268

271269
if IsPackageMarkedForLoading( "FinSetsForCAP", ">= 2023.07-03" ) then
272270

273-
sets := RangeCategoryOfHomomorphismStructure( category );
274-
275-
t_obj := TerminalObject( sets );
276-
277-
size := Length( elements );
278-
279-
RG := FinSet( GROUPS_AS_CATEGORIES_SkeletalFinSets, size );
280-
281-
## Homomorphism structure
282-
##
283-
## Warning: the hom structure is costly for big finite groups.
284-
## TODO: Only do a preprocessing for small groups
285-
AddHomomorphismStructureOnObjects( category,
286-
function( cat, a, b )
287-
288-
return RG;
289-
290-
end );
291-
292-
## Precomputatation of the multiplication maps
293-
## [g,h] -> List encoding the multiplication map (x -> G[g] * x * G[h])
294-
295-
## take Size( SymmetricGroup( 5 ) ) as a first guess
296-
if size <= 120 then
297-
298-
## heavy precomputation, only do for reasonable sizes
299-
300-
HOM_PERMUTATION_ARRAY :=
301-
List( [ 1 .. size ], g ->
302-
List( [ 1 .. size ], h ->
303-
List( elements, x -> -1 + Position( elements, elements[g] * x * elements[h] ) )
304-
)
305-
);
306-
307-
## Should this function have a cache?
308-
##
309-
AddHomomorphismStructureOnMorphisms( category,
310-
function( cat, alpha, beta )
311-
312-
return MapOfFinSets(
313-
GROUPS_AS_CATEGORIES_SkeletalFinSets,
314-
RG,
315-
HOM_PERMUTATION_ARRAY[ PositionWithinElements( alpha ) ][ PositionWithinElements( beta ) ],
316-
RG
317-
);
318-
319-
end );
320-
321-
else
322-
323-
## Should this function have a cache?
324-
##
325-
AddHomomorphismStructureOnMorphisms( category,
326-
function( cat, alpha, beta )
327-
328-
return MapOfFinSets(
329-
GROUPS_AS_CATEGORIES_SkeletalFinSets,
330-
RG,
331-
List( elements, x -> -1 + Position( elements, elements[PositionWithinElements( alpha )] * x * elements[PositionWithinElements( beta )] ) ),
332-
RG
333-
);
334-
335-
end );
336-
337-
fi;
338-
339-
340-
341-
##
342-
AddDistinguishedObjectOfHomomorphismStructure( category,
343-
function( cat )
344-
345-
return t_obj;
346-
347-
end );
348-
349-
##
350-
AddInterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure( category,
351-
function( cat, alpha )
352-
return MapOfFinSets(
353-
GROUPS_AS_CATEGORIES_SkeletalFinSets,
354-
t_obj,
355-
[ -1 + PositionWithinElements( alpha ) ],
356-
RG
357-
);
358-
end );
359-
360-
##
361-
AddInterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism( category,
362-
function( cat, a, b, mor )
363-
return GroupAsCategoryMorphism(
364-
category,
365-
elements[ 1 + AsList( mor )[1] ]
366-
);
367-
end );
271+
INSTALL_HOMOMORPHISM_STRUCTURE_FOR_GROUP_AS_CATEGORY( category );
368272

369273
fi;
274+
370275
fi;
371276

372277
end );
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
# GroupsAsCategoriesForCAP: Groups as categories on one object
3+
#
4+
# Declarations
5+
#
6+
#! @Chapter Groups as categories
7+
8+
####################################
9+
##
10+
#! @Section GAP Categories
11+
##
12+
####################################
13+
14+
DeclareGlobalFunction( "SET_HOMOMORPHISM_STRUCTURE_ATTRIBUTES_FOR_GROUP_AS_CATEGORY" );
15+
16+
DeclareGlobalFunction( "INSTALL_HOMOMORPHISM_STRUCTURE_FOR_GROUP_AS_CATEGORY" );
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
# GroupsAsCategoriesForCAP: Groups as categories on one object
3+
#
4+
# Implementations
5+
#
6+
7+
BindGlobal( "GROUPS_AS_CATEGORIES_SkeletalFinSets", SkeletalCategoryOfFiniteSets( : overhead := false ) );
8+
9+
InstallGlobalFunction( SET_HOMOMORPHISM_STRUCTURE_ATTRIBUTES_FOR_GROUP_AS_CATEGORY,
10+
11+
function( category )
12+
13+
SetRangeCategoryOfHomomorphismStructure( category, GROUPS_AS_CATEGORIES_SkeletalFinSets );
14+
SetIsEquippedWithHomomorphismStructure( category, true );
15+
16+
end );
17+
18+
InstallGlobalFunction( INSTALL_HOMOMORPHISM_STRUCTURE_FOR_GROUP_AS_CATEGORY,
19+
20+
function( category )
21+
local sets, t_obj, elements, size, RG, HOM_PERMUTATION_ARRAY;
22+
23+
sets := RangeCategoryOfHomomorphismStructure( category );
24+
25+
t_obj := TerminalObject( sets );
26+
27+
elements := ElementsOfUnderlyingGroup( category );
28+
29+
size := Length( elements );
30+
31+
RG := FinSet( GROUPS_AS_CATEGORIES_SkeletalFinSets, size );
32+
33+
## Homomorphism structure
34+
##
35+
## Warning: the hom structure is costly for big finite groups.
36+
## TODO: Only do a preprocessing for small groups
37+
AddHomomorphismStructureOnObjects( category,
38+
function( cat, a, b )
39+
40+
return RG;
41+
42+
end );
43+
44+
## Precomputatation of the multiplication maps
45+
## [g,h] -> List encoding the multiplication map (x -> G[g] * x * G[h])
46+
47+
## take Size( SymmetricGroup( 5 ) ) as a first guess
48+
if size <= 120 then
49+
50+
## heavy precomputation, only do for reasonable sizes
51+
52+
HOM_PERMUTATION_ARRAY :=
53+
List( [ 1 .. size ], g ->
54+
List( [ 1 .. size ], h ->
55+
List( elements, x -> -1 + Position( elements, elements[g] * x * elements[h] ) )
56+
)
57+
);
58+
59+
## Should this function have a cache?
60+
##
61+
AddHomomorphismStructureOnMorphisms( category,
62+
function( cat, alpha, beta )
63+
64+
return MapOfFinSets(
65+
GROUPS_AS_CATEGORIES_SkeletalFinSets,
66+
RG,
67+
HOM_PERMUTATION_ARRAY[ PositionWithinElements( alpha ) ][ PositionWithinElements( beta ) ],
68+
RG
69+
);
70+
71+
end );
72+
73+
else
74+
75+
## Should this function have a cache?
76+
##
77+
AddHomomorphismStructureOnMorphisms( category,
78+
function( cat, alpha, beta )
79+
80+
return MapOfFinSets(
81+
GROUPS_AS_CATEGORIES_SkeletalFinSets,
82+
RG,
83+
List( elements, x -> -1 + Position( elements, elements[PositionWithinElements( alpha )] * x * elements[PositionWithinElements( beta )] ) ),
84+
RG
85+
);
86+
87+
end );
88+
89+
fi;
90+
91+
##
92+
AddDistinguishedObjectOfHomomorphismStructure( category,
93+
function( cat )
94+
95+
return t_obj;
96+
97+
end );
98+
99+
##
100+
AddInterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure( category,
101+
function( cat, alpha )
102+
return MapOfFinSets(
103+
GROUPS_AS_CATEGORIES_SkeletalFinSets,
104+
t_obj,
105+
[ -1 + PositionWithinElements( alpha ) ],
106+
RG
107+
);
108+
end );
109+
110+
##
111+
AddInterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism( category,
112+
function( cat, a, b, mor )
113+
return GroupAsCategoryMorphism(
114+
category,
115+
elements[ 1 + AsList( mor )[1] ]
116+
);
117+
end );
118+
119+
end );

GroupsAsCategoriesForCAP/init.g

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
#
66

77
ReadPackage( "GroupsAsCategoriesForCAP", "gap/GroupsAsCats.gd" );
8+
9+
ReadPackage( "GroupsAsCategoriesForCAP", "gap/HomomorphismStructure.gd" );

0 commit comments

Comments
 (0)