Skip to content

Commit 7fd865c

Browse files
authored
Merge pull request #1162 from zickgraf/misc
Prepare for converting to Julia
2 parents 10fda45 + 7ede950 commit 7fd865c

24 files changed

+784
-237
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 := "2022.11-16",
13+
Version := "2022.11-17",
1414
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
1515
License := "GPL-2.0-or-later",
1616

CAP/doc/AddFunctions.autodoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,13 @@ The record can have the following components, most of which can be set in the me
100100
functions given to the Add method are installed as methods.
101101

102102
* pre_function (optional): A function which is used as the prefunction of the installed methods, as described above.
103+
Can also be the name of another operation. In this case the pre function of the referenced operation is used.
103104

104105
* pre_function_full (optional): A function which is used as the full prefunction of the installed methods, as described above.
106+
Can also be the name of another operation. In this case the full pre function of the referenced operation is used.
105107

106108
* redirect_function (optional): A function which is used as the redirect function of the installed methods, as described above.
109+
Can also be the name of another operation. In this case the redirect function of the referenced operation is used.
107110

108111
* post_function (optional): A function which is used as the postfunction of the installed methods, as described above.
109112

@@ -160,9 +163,15 @@ The record can have the following components, most of which can be set in the me
160163
* output_source_getter_string (optional): Only valid if the operation returns a morphism: a piece of GAP code which computes the source of the
161164
returned morphism. The input arguments are available via the names given in `input_arguments_names`.
162165

166+
* can_always_compute_output_source_getter (optional): Only valid if `output_source_getter_string` is also set:
167+
Whether the code in `output_source_getter_string` is independent of CAP operations and can thus always be computed without having to check the installed operations of a category.
168+
163169
* output_range_getter_string (optional): Only valid if the operation returns a morphism: a piece of GAP code which computes the range of the
164170
returned morphism. The input arguments are available via the names given in `input_arguments_names`.
165171

172+
* can_always_compute_output_range_getter (optional): Only valid if `output_range_getter_string` is also set:
173+
Whether the code in `output_range_getter_string` is independent of CAP operations and can thus always be computed without having to check the installed operations of a category.
174+
166175
* with_given_object_position (optional): One of the following strings: `"Source"`, `"Range"`, or `"both"`.
167176
Set for the without given operation in a with given pair. Describes whether the source resp. range are given
168177
(as the last argument of the with given operation) or both (as the second and the last argument of the with given operation).

CAP/gap/CAP.gi

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ InstallGlobalFunction( GET_METHOD_CACHE,
102102
function( category, name, number )
103103
local cache, cache_type;
104104

105+
cache := fail;
106+
107+
#= comment for Julia
105108
if IsBound( category!.caches.( name ) ) and IsCachingObject( category!.caches.( name ) ) then
106109

107110
if category!.caches.( name )!.nr_keys <> number then
@@ -137,6 +140,7 @@ InstallGlobalFunction( GET_METHOD_CACHE,
137140
fi;
138141

139142
category!.caches.(name) := cache;
143+
# =#
140144

141145
return cache;
142146

@@ -999,6 +1003,25 @@ end );
9991003
##
10001004
#######################################
10011005

1006+
# fallback methods for Julia
1007+
InstallMethod( ViewObj,
1008+
[ IsCapCategory ],
1009+
1010+
function ( category )
1011+
1012+
Print( Name( category ) );
1013+
1014+
end );
1015+
1016+
InstallMethod( Display,
1017+
[ IsCapCategory ],
1018+
1019+
function ( category )
1020+
1021+
Print( "A CAP category with name ", Name( category ), "\n" );
1022+
1023+
end );
1024+
10021025
InstallGlobalFunction( CAP_INTERNAL_INSTALL_PRINT_FUNCTION,
10031026

10041027
function( )
@@ -1041,7 +1064,9 @@ InstallMethod( String,
10411064
[ IsCapCategory ],
10421065
Name );
10431066

1067+
#= comment for Julia
10441068
CAP_INTERNAL_INSTALL_PRINT_FUNCTION( );
1069+
# =#
10451070

10461071
InstallGlobalFunction( DisableAddForCategoricalOperations,
10471072

CAP/gap/CategoryConstructor.gi

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ InstallMethod( CategoryConstructor,
99
[ IsRecord ],
1010

1111
function( options )
12-
local known_options_with_filters, filter, CC, default_func_strings, info, unknown_filters, create_func_name, create_func, func_string, underlying_arguments, add, func, option_name, prop, name;
12+
local known_options_with_filters, name, filter, CC, default_func_strings, info, unknown_filters, create_func_name, create_func, func_string, underlying_arguments, add, func, option_name, prop;
1313

1414
## check given options
1515
known_options_with_filters := rec(
1616
name := IsString,
1717
category_filter := IsFilter,
1818
category_object_filter := IsFilter,
1919
category_morphism_filter := IsFilter,
20+
#= comment for Julia
2021
commutative_ring_of_linear_category := IsRing and HasIsCommutative and IsCommutative,
22+
# =#
2123
properties := IsList,
2224
object_constructor := IsFunction,
2325
object_datum := IsFunction,
@@ -65,14 +67,16 @@ InstallMethod( CategoryConstructor,
6567
## create category
6668
if IsBound( options.name ) then
6769

68-
CC := CreateCapCategory( options.name );
70+
name := options.name;
6971

7072
else
7173

72-
CC := CreateCapCategory( );
74+
name := Concatenation( "AutomaticCapCategory", String( CAP_INTERNAL_NAME_COUNTER( ) ) );
7375

7476
fi;
7577

78+
CC := CreateCapCategory( name, options.category_filter, options.category_object_filter, options.category_morphism_filter, IsCapCategoryTwoCell );
79+
7680
CC!.category_as_first_argument := true;
7781

7882
if IsBound( options.supports_empty_limits ) then
@@ -86,24 +90,18 @@ InstallMethod( CategoryConstructor,
8690
## set filters and attributes
8791
if IsBound( options.category_filter ) then
8892

89-
SetFilterObj( CC, options.category_filter );
90-
9193
CC!.compiler_hints.category_filter := options.category_filter;
9294

9395
fi;
9496

9597
if IsBound( options.category_object_filter ) then
9698

97-
AddObjectRepresentation( CC, options.category_object_filter );
98-
9999
CC!.compiler_hints.object_filter := options.category_object_filter;
100100

101101
fi;
102102

103103
if IsBound( options.category_morphism_filter ) then
104104

105-
AddMorphismRepresentation( CC, options.category_morphism_filter );
106-
107105
CC!.compiler_hints.morphism_filter := options.category_morphism_filter;
108106

109107
fi;
@@ -407,7 +405,7 @@ InstallMethod( CategoryConstructor,
407405

408406
if StartsWith( info.return_type, "morphism" ) then
409407

410-
if IsBound( info.output_source_getter_string ) and info.can_always_compute_output_source_getter then
408+
if IsBound( info.output_source_getter_string ) and IsBound( info.can_always_compute_output_source_getter ) and info.can_always_compute_output_source_getter then
411409

412410
func_string := ReplacedStringViaRecord( func_string, rec(
413411
top_source := info.output_source_getter_string,
@@ -421,7 +419,7 @@ InstallMethod( CategoryConstructor,
421419

422420
fi;
423421

424-
if IsBound( info.output_range_getter_string ) and info.can_always_compute_output_range_getter then
422+
if IsBound( info.output_range_getter_string ) and IsBound( info.can_always_compute_output_range_getter ) and info.can_always_compute_output_range_getter then
425423

426424
func_string := ReplacedStringViaRecord( func_string, rec(
427425
top_range := info.output_range_getter_string,

CAP/gap/CategoryMorphisms.gi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,27 @@ InstallMethod( IsWellDefined,
743743
##
744744
###########################
745745

746+
# fallback methods for Julia
747+
InstallMethod( ViewObj,
748+
[ IsCapCategoryMorphism ],
749+
750+
function ( morphism )
751+
752+
# avoid space in front of "in" to distinguish it from the keyword "in"
753+
Print( "<A morphism ", "in ", Name( CapCategory( morphism ) ), ">" );
754+
755+
end );
756+
757+
InstallMethod( Display,
758+
[ IsCapCategoryMorphism ],
759+
760+
function ( morphism )
761+
762+
# avoid space in front of "in" to distinguish it from the keyword "in"
763+
Print( "A morphism ", "in ", Name( CapCategory( morphism ) ), ".\n" );
764+
765+
end );
766+
746767
##
747768
InstallGlobalFunction( CAP_INTERNAL_CREATE_MORPHISM_PRINT,
748769

@@ -819,7 +840,9 @@ InstallGlobalFunction( CAP_INTERNAL_CREATE_MORPHISM_PRINT,
819840

820841
end );
821842

843+
#= comment for Julia
822844
CAP_INTERNAL_CREATE_MORPHISM_PRINT( );
845+
# =#
823846

824847
InstallMethod( String,
825848
[ IsCapCategoryMorphism ],

CAP/gap/CategoryObjects.gi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,27 @@ end );
292292
##
293293
###########################
294294

295+
# fallback methods for Julia
296+
InstallMethod( ViewObj,
297+
[ IsCapCategoryObject ],
298+
299+
function ( object )
300+
301+
# avoid space in front of "in" to distinguish it from the keyword "in"
302+
Print( "<An object ", "in ", Name( CapCategory( object ) ), ">" );
303+
304+
end );
305+
306+
InstallMethod( Display,
307+
[ IsCapCategoryObject ],
308+
309+
function ( object )
310+
311+
# avoid space in front of "in" to distinguish it from the keyword "in"
312+
Print( "An object ", "in ", Name( CapCategory( object ) ), ".\n" );
313+
314+
end );
315+
295316
##
296317
InstallGlobalFunction( CAP_INTERNAL_CREATE_OBJECT_PRINT,
297318

@@ -327,7 +348,9 @@ InstallGlobalFunction( CAP_INTERNAL_CREATE_OBJECT_PRINT,
327348

328349
end );
329350

351+
#= comment for Julia
330352
CAP_INTERNAL_CREATE_OBJECT_PRINT( );
353+
# =#
331354

332355
InstallMethod( String,
333356
[ IsCapCategoryObject ],

CAP/gap/ConstructiveCategoriesRecord.gi

Lines changed: 84 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,98 @@
33
#
44
# Implementations
55
#
6-
InstallValue( CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD, rec(
6+
InstallValue( CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD, rec( ) );
77

8-
EveryCategory := [
9-
"PreCompose", "IdentityMorphism", "IsEqualForObjects", "IsEqualForMorphisms", "IsCongruentForMorphisms" ],
8+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.EveryCategory := [
9+
"PreCompose",
10+
"IdentityMorphism",
11+
"IsEqualForObjects",
12+
"IsEqualForMorphisms",
13+
"IsCongruentForMorphisms",
14+
];
1015

11-
IsEquippedWithHomomorphismStructure := Concatenation( [
12-
"DistinguishedObjectOfHomomorphismStructure",
13-
"HomomorphismStructureOnObjects",
14-
"HomomorphismStructureOnMorphisms",
15-
"InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure",
16-
"InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism" ], ~.EveryCategory ),
1716

18-
IsEnrichedOverCommutativeRegularSemigroup := Concatenation(
19-
[ "AdditionForMorphisms" ], ~.EveryCategory ),
17+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsEquippedWithHomomorphismStructure := Concatenation(
18+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.EveryCategory,
19+
[
20+
"DistinguishedObjectOfHomomorphismStructure",
21+
"HomomorphismStructureOnObjects",
22+
"HomomorphismStructureOnMorphisms",
23+
"InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure",
24+
"InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism",
25+
]
26+
);
2027

21-
IsAbCategory := Concatenation( [
22-
"ZeroMorphism",
23-
"IsZeroForMorphisms",
24-
"SubtractionForMorphisms",
25-
"AdditiveInverseForMorphisms" ], ~.IsEnrichedOverCommutativeRegularSemigroup ),
28+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsEnrichedOverCommutativeRegularSemigroup := Concatenation(
29+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.EveryCategory,
30+
[
31+
"AdditionForMorphisms",
32+
]
33+
);
2634

27-
IsLinearCategoryOverCommutativeRing := Concatenation( [
28-
"MultiplyWithElementOfCommutativeRingForMorphisms" ], ~.IsAbCategory ),
35+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAbCategory := Concatenation(
36+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsEnrichedOverCommutativeRegularSemigroup,
37+
[
38+
"ZeroMorphism",
39+
"IsZeroForMorphisms",
40+
"SubtractionForMorphisms",
41+
"AdditiveInverseForMorphisms",
42+
]
43+
);
2944

30-
IsAdditiveCategory := Concatenation( [
31-
"ZeroObject",
32-
"UniversalMorphismFromZeroObject",
33-
"UniversalMorphismIntoZeroObject",
34-
"DirectSum",
35-
"ProjectionInFactorOfDirectSum",
36-
"InjectionOfCofactorOfDirectSum",
37-
"UniversalMorphismIntoDirectSum",
38-
"UniversalMorphismFromDirectSum" ], ~.IsAbCategory ),
45+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsLinearCategoryOverCommutativeRing := Concatenation(
46+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAbCategory,
47+
[
48+
"MultiplyWithElementOfCommutativeRingForMorphisms",
49+
]
50+
);
3951

40-
IsPreAbelianCategory := Concatenation( [
41-
"KernelObject",
42-
"KernelEmbedding",
43-
"KernelLift",
44-
"CokernelObject",
45-
"CokernelProjection",
46-
"CokernelColift"
47-
], ~.IsAdditiveCategory ),
52+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAdditiveCategory := Concatenation(
53+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAbCategory,
54+
[
55+
"ZeroObject",
56+
"UniversalMorphismFromZeroObject",
57+
"UniversalMorphismIntoZeroObject",
58+
"DirectSum",
59+
"ProjectionInFactorOfDirectSum",
60+
"InjectionOfCofactorOfDirectSum",
61+
"UniversalMorphismIntoDirectSum",
62+
"UniversalMorphismFromDirectSum",
63+
]
64+
);
4865

49-
IsAbelianCategory := Concatenation( [
50-
"LiftAlongMonomorphism",
51-
"ColiftAlongEpimorphism" ], ~.IsPreAbelianCategory ),
66+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsPreAbelianCategory := Concatenation(
67+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAdditiveCategory,
68+
[
69+
"KernelObject",
70+
"KernelEmbedding",
71+
"KernelLift",
72+
"CokernelObject",
73+
"CokernelProjection",
74+
"CokernelColift",
75+
]
76+
);
5277

53-
IsAbelianCategoryWithEnoughProjectives := Concatenation( [
54-
"EpimorphismFromSomeProjectiveObject",
55-
"ProjectiveLift"
56-
], ~.IsAbelianCategory ),
78+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAbelianCategory := Concatenation(
79+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsPreAbelianCategory,
80+
[
81+
"LiftAlongMonomorphism",
82+
"ColiftAlongEpimorphism",
83+
]
84+
);
5785

58-
IsAbelianCategoryWithEnoughInjectives := Concatenation( [
59-
"MonomorphismIntoSomeInjectiveObject",
60-
"InjectiveColift"
61-
], ~.IsAbelianCategory )
62-
63-
) );
86+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAbelianCategoryWithEnoughProjectives := Concatenation(
87+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAbelianCategory,
88+
[
89+
"EpimorphismFromSomeProjectiveObject",
90+
"ProjectiveLift",
91+
]
92+
);
6493

94+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAbelianCategoryWithEnoughInjectives := Concatenation(
95+
CAP_INTERNAL_CONSTRUCTIVE_CATEGORIES_RECORD.IsAbelianCategory,
96+
[
97+
"MonomorphismIntoSomeInjectiveObject",
98+
"InjectiveColift",
99+
]
100+
);

0 commit comments

Comments
 (0)