Skip to content

Commit

Permalink
Category as first argument for IntegerCategory
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Kuhmichel committed Aug 16, 2023
1 parent 7f71440 commit 0da18c8
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions CAP/examples/IntegerCategory.g
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ DeclareAttribute( "UnderlyingInteger",
##
############################

integer_category := CreateCapCategory( "Integers",
integer_category := CreateCapCategory( "HomalgIntegers",
IsCategoryOfHomalgIntegers,
IsObjectInCategoryOfHomalgIntegers,
IsMorphismInCategoryOfHomalgIntegers,
IsCapCategoryTwoCell );

integer_category!.category_as_first_argument := false;
integer_category!.category_as_first_argument := true;

#############################
##
Expand All @@ -47,12 +47,9 @@ InstallMethodWithCache( HomalgInteger,
[ IsInt ],

function( integer )
local homalg_integer;

homalg_integer := CreateCapCategoryObjectWithAttributes( integer_category,
UnderlyingInteger, integer );

return homalg_integer;
return CreateCapCategoryObjectWithAttributes( integer_category,
UnderlyingInteger, integer );

end );

Expand All @@ -77,31 +74,32 @@ InstallMethodWithCache( HomalgIntegerMorphism,
[ IsObjectInCategoryOfHomalgIntegers, IsObjectInCategoryOfHomalgIntegers ],

function( source, range )
local morphism;

if UnderlyingInteger( range ) < UnderlyingInteger( source ) then

Error( "such a morphism does not exist" );

fi;

morphism := CreateCapCategoryMorphismWithAttributes( integer_category,
source,
range );

return morphism;
return CreateCapCategoryMorphismWithAttributes( integer_category,
source,
range );

end );

##
AddIsCongruentForMorphisms( integer_category,

ReturnTrue );
function( cat, mor1, mor2 )

return true;

end );

##
AddIsZeroForMorphisms( integer_category,

function( a )
function( cat, a )

return true;

Expand All @@ -110,7 +108,7 @@ end );
##
AddAdditionForMorphisms( integer_category,

function( a, b )
function( cat, a, b )

return a;

Expand All @@ -119,12 +117,16 @@ end );
##
AddAdditiveInverseForMorphisms( integer_category,

IdFunc );
function( cat, mor )

return mor;

end );

##
AddZeroMorphism( integer_category,

function( a, b )
function( cat, a, b )

return HomalgIntegerMorphism( a, b );

Expand All @@ -133,7 +135,7 @@ end );
##
AddIdentityMorphism( integer_category,

function( obj )
function( cat, obj )

return HomalgIntegerMorphism( obj, obj );

Expand All @@ -142,7 +144,7 @@ end );
##
AddPreCompose( integer_category,

function( mor1, mor2 )
function( cat, mor1, mor2 )

return HomalgIntegerMorphism( Source( mor1 ), Range( mor2 ) );

Expand All @@ -151,7 +153,7 @@ end );
#
AddFiberProduct( integer_category,

function( product_mor )
function( cat, product_mor )
local pullback;

pullback := Gcd( List( product_mor, i -> UnderlyingInteger( Source( i ) ) ) );
Expand All @@ -163,7 +165,7 @@ end );
##
AddProjectionInFactorOfFiberProductWithGivenFiberProduct( integer_category,

function( product_morx, coordinate, pullback )
function( cat, product_morx, coordinate, pullback )
local range;

range := Source( product_morx[ coordinate ] );
Expand All @@ -172,11 +174,10 @@ AddProjectionInFactorOfFiberProductWithGivenFiberProduct( integer_category,

end );


##
AddPushout( integer_category,

function( product_mor )
function( cat, product_mor )
local pushout;

pushout := Lcm( List( product_mor, i -> UnderlyingInteger( Range( i ) ) ) );
Expand All @@ -188,7 +189,7 @@ end );
##
AddInjectionOfCofactorOfPushoutWithGivenPushout( integer_category,

function( product_mor, coordinate, pushout )
function( cat, product_mor, coordinate, pushout )
local source;

source := Range( product_mor[ coordinate ] );
Expand All @@ -200,15 +201,12 @@ end );
##
AddLiftAlongMonomorphism( integer_category,

function( monomorphism, test_morphism )
function( cat, monomorphism, test_morphism )

return HomalgIntegerMorphism( Source( test_morphism ), Source( monomorphism ) );

end );

##


###################################
##
## View
Expand All @@ -234,3 +232,4 @@ InstallMethod( ViewString,
return Concatenation( "<", String( UnderlyingInteger( Source( integer_mor ) ) ), " -> ", String( UnderlyingInteger( Range( integer_mor ) ) ), ">" );

end );

0 comments on commit 0da18c8

Please sign in to comment.