Skip to content

Commit 95ca8cb

Browse files
authored
Merge pull request #1212 from zickgraf/improvements
Miscellaneous changes and improvements
2 parents 25b1580 + 7ee1f52 commit 95ca8cb

File tree

9 files changed

+204
-60
lines changed

9 files changed

+204
-60
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.12-14",
13+
Version := "2022.12-15",
1414
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
1515
License := "GPL-2.0-or-later",
1616

CAP/gap/CAP.gd

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ DeclareGlobalFunction( "DisableAddForCategoricalOperations" );
733733
#############################################
734734

735735
#! For finding performance issues in primitive operations, you can collect timing statistics, see <Ref Sect="Section_Timing_statistics" />.
736+
#! You can use the package `CompilerForCAP` to compile your code.
736737
#! Additionally, CAP has several settings which can improve the performance.
737738
#! In the following some of these are listed.
738739
#! * <C>DeactivateCachingOfCategory</C> or <C>DeactivateDefaultCaching</C>: see <Ref Sect="Section_Caching" />.
@@ -746,9 +747,6 @@ DeclareGlobalFunction( "DisableAddForCategoricalOperations" );
746747
#! instead of <C>AddObject</C> and
747748
#! <C>CreateCapCategoryMorphismWithAttributes</C> (<Ref Sect="Section_Adding_Morphisms_to_a_Category" />)
748749
#! instead of <C>AddMorphism</C>.
749-
#! * Add all attribute testers (<C>Has...</C>) of your objects resp. morphisms to the filters passed to
750-
#! <C>AddObjectRepresentation</C> (<Ref Sect="Section_Adding_Objects_to_a_Category" />) resp.
751-
#! <C>AddMorphismRepresentation</C> (<Ref Sect="Section_Adding_Morphisms_to_a_Category" />).
752750
#! * Pass the option <C>overhead := false</C> to <C>CreateCapCategory</C>.
753751
#! Note: this may have unintended effects. Use with care!
754752

CAP/gap/CAP.gi

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,30 @@ InstallGlobalFunction( "CREATE_CAP_CATEGORY_OBJECT",
164164
function( obj_rec, name, category_filter, object_filter, morphism_filter, two_cell_filter, object_datum_type, morphism_datum_type, two_cell_datum_type )
165165
local filter, obj, operation_name;
166166

167+
if not IsSpecializationOfFilter( IsCapCategory, category_filter ) then
168+
169+
Error( "the category filter must imply IsCapCategory" );
170+
171+
fi;
172+
173+
if not IsSpecializationOfFilter( IsCapCategoryObject, object_filter ) then
174+
175+
Error( "the object filter must imply IsCapCategoryObject" );
176+
177+
fi;
178+
179+
if not IsSpecializationOfFilter( IsCapCategoryMorphism, morphism_filter ) then
180+
181+
Error( "the morphism filter must imply IsCapCategoryMorphism" );
182+
183+
fi;
184+
185+
if not IsSpecializationOfFilter( IsCapCategoryTwoCell, two_cell_filter ) then
186+
187+
Error( "the two cell filter must imply IsCapCategoryTwoCell" );
188+
189+
fi;
190+
167191
if IsFilter( object_datum_type ) then
168192

169193
object_datum_type := rec( filter := object_datum_type );
@@ -184,14 +208,14 @@ InstallGlobalFunction( "CREATE_CAP_CATEGORY_OBJECT",
184208

185209
obj_rec!.logical_implication_files := StructuralCopy( CATEGORIES_LOGIC_FILES );
186210

187-
filter := NewFilter( Concatenation( name, "InternalCategoryFilter" ), category_filter );
211+
filter := NewFilter( Concatenation( name, "InstanceCategoryFilter" ), category_filter );
188212

189213
obj := ObjectifyWithAttributes( obj_rec, NewType( TheFamilyOfCapCategories, filter ), Name, name );
190214

191215
SetCategoryFilter( obj, filter );
192216

193217
# object filter
194-
filter := NewCategory( Concatenation( name, "ObjectFilter" ), object_filter );
218+
filter := NewCategory( Concatenation( name, "InstanceObjectFilter" ), object_filter );
195219

196220
SetObjectFilter( obj, filter );
197221
SetObjectDatumType( obj, object_datum_type );
@@ -200,7 +224,7 @@ InstallGlobalFunction( "CREATE_CAP_CATEGORY_OBJECT",
200224
obj!.object_type := NewType( TheFamilyOfCapCategoryObjects, filter );
201225

202226
# morphism filter
203-
filter := NewCategory( Concatenation( name, "MorphismFilter" ), morphism_filter );
227+
filter := NewCategory( Concatenation( name, "InstanceMorphismFilter" ), morphism_filter );
204228

205229
SetMorphismFilter( obj, filter );
206230
SetMorphismDatumType( obj, morphism_datum_type );
@@ -209,7 +233,7 @@ InstallGlobalFunction( "CREATE_CAP_CATEGORY_OBJECT",
209233
obj!.morphism_type := NewType( TheFamilyOfCapCategoryMorphisms, filter );
210234

211235
# two cell filter
212-
filter := NewCategory( Concatenation( name, "TwoCellFilter" ), two_cell_filter );
236+
filter := NewCategory( Concatenation( name, "InstanceTwoCellFilter" ), two_cell_filter );
213237

214238
SetTwoCellFilter( obj, filter );
215239
SetTwoCellDatumType( obj, two_cell_datum_type );

CAP/gap/CategoryMorphisms.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ DeclareOperation( "AddMorphism",
373373

374374
#! @Arguments category, filter
375375
#! @Description
376+
#! **Deprecated**: use <Ref Func="CreateCapCategoryWithDataTypes" /> instead.
376377
#! The argument <A>filter</A> is used to create a morphism type for the
377378
#! category <A>category</A>, which is then used in <C>ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes</C>
378379
#! to objectify morphisms for this category. <A>filter</A> must imply `IsCapCategoryMorphism`.
@@ -383,7 +384,7 @@ DeclareOperation( "AddMorphismRepresentation",
383384
#! @Description
384385
#! Objectifies the morphism <A>morphism</A> with the type created
385386
#! for morphisms in the category <A>category</A>. The type
386-
#! is created by passing a representation to <C>AddMorphismRepresentation</C>.
387+
#! is created by passing a morphism filter to <Ref Func="CreateCapCategoryWithDataTypes" />.
387388
#! Morphisms which are objectified using this method do not have to be passed
388389
#! to the <C>AddMorphism</C> function.
389390
#! The arguments <C>source</C> and <C>range</C> are assumed to be objectified.

CAP/gap/CategoryMorphisms.gi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ InstallMethod( AddMorphismRepresentation,
255255

256256
fi;
257257

258+
if IsBound( category!.initially_known_categorical_properties ) then
259+
260+
Error( "calling AddMorphismRepresentation after adding functions to the category is not supported" );
261+
262+
fi;
263+
258264
category!.morphism_representation := representation;
259265
category!.morphism_type := NewType( TheFamilyOfCapCategoryMorphisms, representation and MorphismFilter( category ) and HasSource and HasRange and HasCapCategory );
260266

CAP/gap/CategoryObjects.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ DeclareOperation( "AddObject",
212212

213213
#! @Arguments category, filter
214214
#! @Description
215+
#! **Deprecated**: use <Ref Func="CreateCapCategoryWithDataTypes" /> instead.
215216
#! The argument <A>filter</A> is used to create an object type for the
216217
#! category <A>category</A>, which is then used in <C>ObjectifyObjectForCAPWithAttributes</C>
217218
#! to objectify objects for this category. <A>filter</A> must imply `IsCapCategoryObject`.
@@ -222,7 +223,7 @@ DeclareOperation( "AddObjectRepresentation",
222223
#! @Description
223224
#! Objectifies the object <A>object</A> with the type created
224225
#! for objects in the category <A>category</A>. The type
225-
#! is created by passing a representation to <C>AddObjectRepresentation</C>.
226+
#! is created by passing an object filter to <Ref Func="CreateCapCategoryWithDataTypes" />.
226227
#! Objects which are objectified using this method do not have to be passed
227228
#! to the <C>AddObject</C> function.
228229
#! The optional arguments behave like the corresponding arguments in <C>ObjectifyWithAttributes</C>.

CAP/gap/CategoryObjects.gi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ InstallMethod( AddObjectRepresentation,
236236

237237
fi;
238238

239+
if IsBound( category!.initially_known_categorical_properties ) then
240+
241+
Error( "calling AddObjectRepresentation after adding functions to the category is not supported" );
242+
243+
fi;
244+
239245
category!.object_representation := representation;
240246
category!.object_type := NewType( TheFamilyOfCapCategoryObjects, representation and ObjectFilter( category ) and HasCapCategory );
241247

FreydCategoriesForCAP/gap/FreydCategory.gi

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,14 @@ BindGlobal( "InfoFreydCategoriesForCAP", NewInfoClass("InfoFreydCategoriesForCAP
2222

2323
##
2424
InstallGlobalFunction( FREYD_CATEGORY,
25-
function( underlying_category, args... )
25+
function( underlying_category )
2626
local name, freyd_category, conditions;
2727

2828
if not IsValidInputForFreydCategory( underlying_category ) then
2929
return false;
3030
fi;
3131

32-
if Length( args ) = 0 then
33-
34-
name := Concatenation( "Freyd( ", Name( underlying_category ), " )" );
35-
36-
elif Length( args ) = 1 then
37-
38-
if not IsString( args[1] ) then
39-
40-
Error( "The second argument of FREYD_CATEGORY must be a string." );
41-
42-
fi;
43-
44-
name := args[1];
45-
46-
else
47-
48-
Error( "FREYD_CATEGORY must be called with at most two arguments." );
49-
50-
fi;
32+
name := Concatenation( "Freyd( ", Name( underlying_category ), " )" );
5133

5234
freyd_category := CreateCapCategory( name );
5335

FreydCategoriesForCAP/gap/GradedModulePresentationsByFreyd/GradedModulePresentationsByFreyd.gi

Lines changed: 156 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,84 @@ end );
2828
##
2929
InstallMethod( FreydCategory,
3030
[ IsCategoryOfGradedRows ],
31-
function( underlying_category )
32-
local category, graded_ring;
33-
34-
graded_ring := UnderlyingGradedRing( underlying_category );
35-
36-
category := FREYD_CATEGORY( underlying_category, Concatenation( "Category of f.p. graded left modules over ", RingName( graded_ring ) ) );
37-
38-
SetFilterObj( category, IsFpGradedLeftModules );
39-
40-
AddObjectRepresentation( category, IsFreydCategoryObject and HasRelationMorphism and IsFpGradedLeftModulesObject );
41-
42-
AddMorphismRepresentation( category, IsFreydCategoryMorphism and HasUnderlyingMorphism and IsFpGradedLeftModulesMorphism );
43-
44-
return category;
45-
31+
32+
function( underlying_category )
33+
local graded_ring, freyd, object_constructor, modeling_tower_object_constructor, object_datum, modeling_tower_object_datum, morphism_constructor, modeling_tower_morphism_constructor, morphism_datum, modeling_tower_morphism_datum, wrapper;
34+
35+
graded_ring := UnderlyingGradedRing( underlying_category );
36+
37+
freyd := FREYD_CATEGORY( underlying_category );
38+
39+
object_constructor := function ( cat, relation_morphism )
40+
41+
return CreateCapCategoryObjectWithAttributes( cat, RelationMorphism, relation_morphism );
42+
43+
end;
44+
45+
modeling_tower_object_constructor := function ( cat, relation_morphism )
46+
47+
return CreateCapCategoryObjectWithAttributes( ModelingCategory( cat ), RelationMorphism, relation_morphism );
48+
49+
end;
50+
51+
object_datum := function ( cat, object )
52+
53+
return RelationMorphism( object );
54+
55+
end;
56+
57+
modeling_tower_object_datum := function ( cat, object )
58+
59+
return RelationMorphism( object );
60+
61+
end;
62+
63+
morphism_constructor := function ( cat, source, underlying_morphism, range )
64+
65+
return CreateCapCategoryMorphismWithAttributes( cat, source, range, UnderlyingMorphism, underlying_morphism );
66+
67+
end;
68+
69+
modeling_tower_morphism_constructor := function ( cat, source, underlying_morphism, range )
70+
71+
return CreateCapCategoryMorphismWithAttributes( ModelingCategory( cat ), source, range, UnderlyingMorphism, underlying_morphism );
72+
73+
end;
74+
75+
morphism_datum := function ( cat, morphism )
76+
77+
return UnderlyingMorphism( morphism );
78+
79+
end;
80+
81+
modeling_tower_morphism_datum := function ( cat, morphism )
82+
83+
return UnderlyingMorphism( morphism );
84+
85+
end;
86+
87+
wrapper := WrapperCategory( freyd, rec(
88+
name := Concatenation( "Category of f.p. graded left modules over ", RingName( graded_ring ) ),
89+
category_filter := IsFreydCategory and IsFpGradedLeftModules,
90+
category_object_filter := IsFreydCategoryObject and HasRelationMorphism and IsFpGradedLeftModulesObject,
91+
category_morphism_filter := IsFreydCategoryMorphism and HasUnderlyingMorphism and IsFpGradedLeftModulesMorphism,
92+
object_constructor := object_constructor,
93+
object_datum := object_datum,
94+
morphism_constructor := morphism_constructor,
95+
morphism_datum := morphism_datum,
96+
modeling_tower_object_constructor := modeling_tower_object_constructor,
97+
modeling_tower_object_datum := modeling_tower_object_datum,
98+
modeling_tower_morphism_constructor := modeling_tower_morphism_constructor,
99+
modeling_tower_morphism_datum := modeling_tower_morphism_datum,
100+
# enforce defaults
101+
only_primitive_operations := false,
102+
wrap_range_of_hom_structure := false,
103+
) );
104+
105+
SetUnderlyingCategory( wrapper, underlying_category );
106+
107+
return wrapper;
108+
46109
end );
47110

48111
# compute the category S-fpgrmod for a toric variety
@@ -58,19 +121,82 @@ end );
58121
##
59122
InstallMethod( FreydCategory,
60123
[ IsCategoryOfGradedColumns ],
61-
function( underlying_category )
62-
local category, graded_ring;
63-
64-
graded_ring := UnderlyingGradedRing( underlying_category );
65-
66-
category := FREYD_CATEGORY( underlying_category, Concatenation( "Category of f.p. graded right modules over ", RingName( graded_ring ) ) );
67-
68-
SetFilterObj( category, IsFpGradedRightModules );
69-
70-
AddObjectRepresentation( category, IsFreydCategoryObject and HasRelationMorphism and IsFpGradedRightModulesObject );
71-
72-
AddMorphismRepresentation( category, IsFreydCategoryMorphism and HasUnderlyingMorphism and IsFpGradedRightModulesMorphism );
73-
74-
return category;
75-
124+
125+
function( underlying_category )
126+
local graded_ring, freyd, object_constructor, modeling_tower_object_constructor, object_datum, modeling_tower_object_datum, morphism_constructor, modeling_tower_morphism_constructor, morphism_datum, modeling_tower_morphism_datum, wrapper;
127+
128+
graded_ring := UnderlyingGradedRing( underlying_category );
129+
130+
freyd := FREYD_CATEGORY( underlying_category );
131+
132+
object_constructor := function ( cat, relation_morphism )
133+
134+
return CreateCapCategoryObjectWithAttributes( cat, RelationMorphism, relation_morphism );
135+
136+
end;
137+
138+
modeling_tower_object_constructor := function ( cat, relation_morphism )
139+
140+
return CreateCapCategoryObjectWithAttributes( ModelingCategory( cat ), RelationMorphism, relation_morphism );
141+
142+
end;
143+
144+
object_datum := function ( cat, object )
145+
146+
return RelationMorphism( object );
147+
148+
end;
149+
150+
modeling_tower_object_datum := function ( cat, object )
151+
152+
return RelationMorphism( object );
153+
154+
end;
155+
156+
morphism_constructor := function ( cat, source, underlying_morphism, range )
157+
158+
return CreateCapCategoryMorphismWithAttributes( cat, source, range, UnderlyingMorphism, underlying_morphism );
159+
160+
end;
161+
162+
modeling_tower_morphism_constructor := function ( cat, source, underlying_morphism, range )
163+
164+
return CreateCapCategoryMorphismWithAttributes( ModelingCategory( cat ), source, range, UnderlyingMorphism, underlying_morphism );
165+
166+
end;
167+
168+
morphism_datum := function ( cat, morphism )
169+
170+
return UnderlyingMorphism( morphism );
171+
172+
end;
173+
174+
modeling_tower_morphism_datum := function ( cat, morphism )
175+
176+
return UnderlyingMorphism( morphism );
177+
178+
end;
179+
180+
wrapper := WrapperCategory( freyd, rec(
181+
name := Concatenation( "Category of f.p. graded right modules over ", RingName( graded_ring ) ),
182+
category_filter := IsFreydCategory and IsFpGradedRightModules,
183+
category_object_filter := IsFreydCategoryObject and HasRelationMorphism and IsFpGradedRightModulesObject,
184+
category_morphism_filter := IsFreydCategoryMorphism and HasUnderlyingMorphism and IsFpGradedRightModulesMorphism,
185+
object_constructor := object_constructor,
186+
object_datum := object_datum,
187+
morphism_constructor := morphism_constructor,
188+
morphism_datum := morphism_datum,
189+
modeling_tower_object_constructor := modeling_tower_object_constructor,
190+
modeling_tower_object_datum := modeling_tower_object_datum,
191+
modeling_tower_morphism_constructor := modeling_tower_morphism_constructor,
192+
modeling_tower_morphism_datum := modeling_tower_morphism_datum,
193+
# enforce defaults
194+
only_primitive_operations := false,
195+
wrap_range_of_hom_structure := false,
196+
) );
197+
198+
SetUnderlyingCategory( wrapper, underlying_category );
199+
200+
return wrapper;
201+
76202
end );

0 commit comments

Comments
 (0)