Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples and tests #363

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
362 changes: 362 additions & 0 deletions FreydCategoriesForCAP/examples/FreydCategoryOfGradedRowsAndColumns.g

Large diffs are not rendered by default.

92 changes: 92 additions & 0 deletions FreydCategoriesForCAP/gap/FreydCategory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ DeclareAttribute( "AsFreydCategoryObject",
DeclareAttribute( "AsFreydCategoryMorphism",
IsCapCategoryMorphism );


####################################
##
#! @Section Attributes
Expand Down Expand Up @@ -98,3 +99,94 @@ DeclareGlobalFunction( "IsValidInputForFreydCategory" );
#! @Arguments objects a, b
DeclareOperationWithCache( "INTERNAL_HOM_EMBEDDING",
[ IsFreydCategoryObject, IsFreydCategoryObject ] );


####################################################################################
##
#! @Section Convenient methods for tensor products of freyd objects and morphisms
##
####################################################################################

#!
DeclareOperation( "\*",
[ IsFreydCategoryObject, IsFreydCategoryObject ] );

#!
DeclareOperation( "\^",
[ IsFreydCategoryObject, IsInt ] );

#!
DeclareOperation( "\*",
[ IsFreydCategoryMorphism, IsFreydCategoryMorphism ] );

#!
DeclareOperation( "\^",
[ IsFreydCategoryMorphism, IsInt ] );


####################################################
##
#! @Section Embedding functor for additive categories
##
####################################################

#! @Description
#! The argument is a CapCategory $C$. Provided that $C$ admits a Freyd category, this
#! attribute will be set to be the embedding functor into this Freyd category.
#! @Returns a functor
#! @Arguments C
DeclareAttribute( "EmbeddingIntoFreydCategory",
IsCapCategory );


####################################################
##
#! @Section Functor BestProjectiveApproximation
##
####################################################

#! @Description
#! The argument is an object $A$ in a Freyd category. The output will be
#! the object in the underlying additive category, which serves as the best
#! approximation of the given object $A$.
#! @Returns an object in the underlying additive category
#! @Arguments A
DeclareAttribute( "BestProjectiveApproximation",
IsFreydCategoryObject );

#! @Description
#! The argument is an object $A$ in a Freyd category. The output will be the
#! canonical morphism from the object $A$ into this best projective
#! approximation, the latter canonically understood as object in the Freyd category.
#! @Returns a morphism in the Freyd category
#! @Arguments A
DeclareAttribute( "MorphismIntoBestProjectiveApproximation",
IsCapCategoryObject );

#! @Description
#! The argument is a morphism $\alpha$ in a Freyd category. The output is the
#! morphism in the underlying additive category, which best approximates $\alpha$.
#! @Returns a morphism in the underlying additive category
#! @Arguments $\alpha$
DeclareAttribute( "BestProjectiveApproximation",
IsCapCategoryMorphism );

#! @Description
#! The argument is a CapCategory $C$. Provided that $C$ admits a Freyd category, this
#! attribute will be set to be the functor that maps objects and morphisms in the Freyd
#! category to their best projective approximations in the underlying additive category.
#! @Returns a functor
#! @Arguments C
DeclareAttribute( "BestProjectiveApproximationFunctor",
IsCapCategory );

#! @Description
#! The argument is a CapCategory $C$. Provided that $C$ admits a Freyd category, this
#! attribute will be set to be the functor that maps objects and morphisms in the Freyd
#! category to their best projective approximations in the underlying additive category.
#! In contrast to BestProjectiveApproximationFunctor, we canonically embed these projective
#! objects into the Freyd category. So this returns an autofunctor of the Freyd category.
#! @Returns a functor
#! @Arguments C
DeclareAttribute( "BestEmbeddedProjectiveApproximationFunctor",
IsCapCategory );
282 changes: 282 additions & 0 deletions FreydCategoriesForCAP/gap/FreydCategory.gi
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ InstallMethod( FreydCategoryMorphism,
FREYD_CATEGORY_MORPHISM
);


####################################
##
## Attributes
Expand Down Expand Up @@ -1639,3 +1640,284 @@ InstallGlobalFunction( IsValidInputForFreydCategory,
return result;

end );


####################################################################################
##
## Section Powers of objects and morphisms
##
####################################################################################

# for convenience allow "*" to indicate the tensor product on objects
InstallMethod( \*,
"powers of presentations",
[ IsFreydCategoryObject, IsFreydCategoryObject ],
function( freyd_object1, freyd_object2 )

return TensorProductOnObjects( freyd_object1, freyd_object2 );

end );

# for convenience allow "*" to indicate the tensor product on morphisms
InstallMethod( \*,
"powers of presentations",
[ IsFreydCategoryMorphism, IsFreydCategoryMorphism ],
function( freyd_morphism1, freyd_morphism2 )

return TensorProductOnMorphisms( freyd_morphism1, freyd_morphism2 );

end );

# allow "^p" to indicate the p-th power, i.e. p-times tensor product of an object with itself
InstallMethod( \^,
"powers of presentations",
[ IsFreydCategoryObject, IsInt ],
function( freyd_object, power )
local res, i;

if power < 0 then

return Error( "The power must be non-negative! \n" );

elif power = 0 then

return TensorUnit( CapCategory( freyd_object ) );

elif power = 1 then

return freyd_object;

else

res := freyd_object;

for i in [ 1 .. power ] do
res := res * freyd_object;
od;

return res;

fi;

end );

# allow "^p" to indicate the p-th power, i.e. p-times tensor product of a morphism with itself
InstallMethod( \^,
"powers of presentations",
[ IsFreydCategoryMorphism, IsInt ],
function( freyd_morphism, power )
local res, i;

if power < 0 then

return Error( "The power must be non-negative! \n" );

elif power = 0 then

return IdentityMorphism( TensorUnit( CapCategory( freyd_morphism ) ) );

elif power = 1 then

return freyd_morphism;

else

res := freyd_morphism;

for i in [ 1 .. power ] do
res := res * freyd_morphism;
od;

return res;

fi;


#############################################################################
##
## Embedding of additive category into its Freyd category
##
#############################################################################

InstallMethod( EmbeddingIntoFreydCategory,
[ IsCapCategory ],
function( additive_category )
local freyd_category, functor;

# check for valid input
if not IsValidInputForFreydCategory( additive_category ) then

Error( "The input category does not admit a Freyd category" );
return 0;

fi;

# define the Freyd category
freyd_category := FreydCategory( additive_category );

# and set up the basics of this functor
functor := CapFunctor( Concatenation( "Embedding functor of ", Name( additive_category ),
" into its Freyd category" ),
additive_category,
freyd_category
);

# now define the operation on the objects
AddObjectFunction( functor,

function( object )

return AsFreydCategoryObject( object );

end );

# and the operation on the morphisms
AddMorphismFunction( functor,

function( new_source, morphism, new_range )

return AsFreydCategoryMorphism( morphism );

end );

# and return this functor
return functor;

end );


####################################################
##
## Section Functor BestProjectiveApproximation
##
####################################################

## Morhpism into best projective approximation
InstallMethod( MorphismIntoBestProjectiveApproximation,
[ IsFreydCategoryObject ],

function( freyd_object )
local mor;

mor := WeakCokernelProjection( RelationMorphism( freyd_object ) );

return FreydCategoryMorphism( freyd_object, mor, AsFreydCategoryObject( Range( mor ) ) );

end );

## Best projective approximation of a Freyd_object
InstallMethod( BestProjectiveApproximation,
[ IsFreydCategoryObject ],

function( freyd_object )

return WeakCokernelObject( RelationMorphism( freyd_object ) );

end );

## Best projective approximation of a Freyd_morphism
InstallMethod( BestProjectiveApproximation,
[ IsFreydCategoryMorphism ],

function( freyd_mor )
local mor1, mor2, new_mor_datum;

mor1 := MorphismIntoBestProjectiveApproximation( Source( freyd_mor ) );
mor2 := PreCompose( MorphismDatum( freyd_mor ), MorphismIntoBestProjectiveApproximation( Range( freyd_mor ) ) );

return WeakColiftAlongEpimorphism( mor1, mor2 );

end );

InstallMethod( BestProjectiveApproximationFunctor,
[ IsCapCategory ],
function( additive_category )
local freyd_category, functor;

# check for valid input
if not IsValidInputForFreydCategory( additive_category ) then

Error( "The input category does not admit a Freyd category" );
return 0;

fi;

# define the Freyd category
freyd_category := FreydCategory( additive_category );

# and set up the basics of this functor
functor := CapFunctor( Concatenation( "Best projective approximation functor of the Freyd category of ",
Name( additive_category ) ),
freyd_category,
additive_category
);

# now define the operation on the objects
AddObjectFunction( functor,

function( object )

return BestProjectiveApproximation( object );

end );

# and the operation on the morphisms
AddMorphismFunction( functor,

function( new_source, morphism, new_range )

return BestProjectiveApproximation( morphism );

end );

# and return this functor
return functor;

end );


InstallMethod( BestEmbeddedProjectiveApproximationFunctor,
[ IsCapCategory ],
function( additive_category )
local freyd_category, functor;

# check for valid input
if not IsValidInputForFreydCategory( additive_category ) then

Error( "The input category does not admit a Freyd category" );
return 0;

fi;

# define the Freyd category
freyd_category := FreydCategory( additive_category );

# and set up the basics of this functor
functor := CapFunctor( Concatenation( "Best embedded projective approximation functor of the Freyd category of ",
Name( additive_category ) ),
freyd_category,
additive_category
);

# now define the operation on the objects
AddObjectFunction( functor,

function( object )

return AsFreydCategoryObject( BestProjectiveApproximation( object ) );

end );

# and the operation on the morphisms
AddMorphismFunction( functor,

function( new_source, morphism, new_range )

return AsFreydCategoryMorphism( BestProjectiveApproximation( morphism ) );

end );

# and return this functor
return functor;

end );
Loading