Goto Chapter: Top 1 2 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

2 Examples and tests
 2.1 Tests

2 Examples and tests

2.1 Tests

gap> ## As an example for the usage of the attribute category,
> ## we install the category of pairs ( A, alpha: A -> A )
> ## consisting of an object equipped with an endomorphism.
> 
> LoadPackage( "AttributeCategoryForCAP", false );
true
gap> LoadPackage( "LinearAlgebraForCAP", false );
true
gap> #################################
> 
> ## Note: This filter implies IsCategoryWithAttributesObject
> DeclareCategory( "IsObjectWithEndomorphism",
>                  IsCategoryWithAttributesObject );;
gap> DeclareRepresentation( "IsObjectWithEndomorphismRep",
>                        IsObjectWithEndomorphism and IsAttributeStoringRep,
>                        [ ] );;
gap> BindGlobal( "TheFamilyOfObjectsWithEndomorphism",
>         NewFamily( "TheFamilyOfObjectsWithEndomorphism" ) );;
gap> BindGlobal( "TheTypeOfObjectsWithEndomorphism",
>         NewType( TheFamilyOfObjectsWithEndomorphism,
>                 IsObjectWithEndomorphismRep ) );;
gap> ## Note: This filter implies IsCategoryWithAttributesMorphism
> DeclareCategory( "IsMorphismOfObjectsWithEndomorphism",
>                  IsCategoryWithAttributesMorphism );;
gap> DeclareRepresentation( "IsMorphismOfObjectsWithEndomorphismRep",
>                        IsMorphismOfObjectsWithEndomorphism and IsAttributeStoringRep,
>                        [ ] );;
gap> BindGlobal( "TheFamilyOfMorphismsOfObjectsWithEndomorphism",
>         NewFamily( "TheFamilyOfMorphismsOfObjectsWithEndomorphism" ) );;
gap> BindGlobal( "TheTypeOfMorphismsOfObjectsWithEndomorphism",
>         NewType( TheFamilyOfMorphismsOfObjectsWithEndomorphism,
>                 IsMorphismOfObjectsWithEndomorphismRep ) );;
gap> #################################
> 
> Q := HomalgFieldOfRationals();;
gap> underlying_category := MatrixCategory( Q );;
gap> ## We create a "void" CapCategory here and set its properties (abelian, monoidal) in the beginning
> category_of_objects_with_endomorphism := CreateCapCategory( "Category of objects with endomorphisms" );;
gap> SetIsAbelianCategory( category_of_objects_with_endomorphism, true );;
gap> SetIsRigidSymmetricClosedMonoidalCategory( category_of_objects_with_endomorphism, true );;
gap> SetIsStrictMonoidalCategory( category_of_objects_with_endomorphism, true );;
gap> ## This record will be the input of the function that enhances underlying_category with attributes
> structure_record := rec(
>       underlying_category := underlying_category,
>       category_with_attributes := category_of_objects_with_endomorphism
>     );;
gap> ## We can give the types of objects and morphisms to the structure_record.
> ## In this case, object and morphism constructors will automatically be generated.
> ## Alternatively, you can provide your own constructors via
> ## structure_record.ObjectConstructor and structure_record.MorphismConstructor.
> ## Note: If you provide your own object constructor,
> ## you have to set the attributes UnderlyingCell, ObjectAttributesAsList, and UnderlyingCategory.
> ## If you write your own morphism constructor,
> ## you have to set the attributes UnderlyingCell, and UnderlyingCategory
> structure_record.object_type := TheTypeOfObjectsWithEndomorphism;;
gap> structure_record.morphism_type := TheTypeOfMorphismsOfObjectsWithEndomorphism;;
gap> ## This is the mathematical core: provide the functions that enhance objects with attributes
> structure_record.ZeroObject :=
>   function( underlying_zero_object )
>       
>       return [ ZeroMorphism( underlying_zero_object, underlying_zero_object ) ]; end;;
gap> structure_record.DirectSum :=
>   function( obj_list, underlying_direct_sum )
>       
>       return [ DirectSumFunctorial( List( obj_list, obj -> ObjectAttributesAsList( obj )[1] ) ) ]; end;;
gap> structure_record.Lift :=
>   function( mono, range )
>       
>       return [ LiftAlongMonomorphism( mono, PreCompose( mono, ObjectAttributesAsList( range )[1] ) ) ]; end;;
gap> structure_record.Colift :=
>   function( epi, source )
>       
>       return [ ColiftAlongEpimorphism( epi, PreCompose( ObjectAttributesAsList( source )[1], epi ) ) ]; end;;
gap> structure_record.TensorUnit :=
>   function( underlying_tensor_unit )
>       
>       return [ IdentityMorphism( underlying_tensor_unit ) ]; end;;
gap> structure_record.TensorProductOnObjects :=
>   function( object1, object2, underlying_tensor_product )
>       
>       return [ TensorProductOnMorphisms( ObjectAttributesAsList( object1 )[1], ObjectAttributesAsList( object2 )[1] ) ]; end;;
gap> structure_record.DualOnObjects :=
>   function( object, dual_object )
>       
>       return [ DualOnMorphisms( ObjectAttributesAsList( object )[1] ) ]; end;;
gap> ## In this particular example, this function would be not necessary since it can be 
> ## derived from the rigidity of the category
> structure_record.InternalHomOnObjects :=
>   function( object1, object2, underlying_internal_hom )
>       
>       return [ TensorProductOnMorphisms( DualOnMorphisms( ObjectAttributesAsList( object1 )[1] ), 
>                ObjectAttributesAsList( object2 )[1] ) ]; end;;
gap> structure_record.NoInstallList := [ "Lift", "Colift" ];;
gap> structure_record.InstallList := [ "LiftAlongMonomorphism", "ColiftAlongEpimorphism" ];;
gap> ## This function installs all the primitive functions for the category_of_objects_with_endomorphism.
> triple := EnhancementWithAttributes( structure_record );;
gap> ## EnhancementWithAttributes alters category_of_objects_with_endomorphism as a side effect:
> IsIdenticalObj( category_of_objects_with_endomorphism, triple[1] );
true
gap> object_constructor := triple[2];;
gap> morphism_constructor := triple[3];;
gap> ## Install equality/ congruence functions manually since they cannot be deduced automatically
> AddIsEqualForObjects( category_of_objects_with_endomorphism,
>   function( cat, object1, object2 )
>     
>     return IsEqualForObjects( UnderlyingCell( object1 ), UnderlyingCell( object2 ) )
>            and IsCongruentForMorphisms( ObjectAttributesAsList( object1 )[1], ObjectAttributesAsList( object2 )[1] ); end );;
gap> AddIsEqualForMorphisms( category_of_objects_with_endomorphism,
>   function( cat, morphism1, morphism2 )
>     
>     return IsCongruentForMorphisms( UnderlyingCell( morphism1 ), UnderlyingCell( morphism2 ) ); end );;
gap> ## Finalize the category
> Finalize( category_of_objects_with_endomorphism );;
gap> ##############################
> 
> ## Example computations
> 
> V := VectorSpaceObject( 2, Q );
<A vector space object over Q of dimension 2>
gap> endo := VectorSpaceMorphism( V, HomalgMatrix( [ [ 0, 1 ], [ 1, 0 ] ], 2, 2, Q ), V );
<A morphism in Category of matrices over Q>
gap> Vendo := object_constructor( V, [ endo ] );
<An object in Category of objects with endomorphisms>
gap> IsCongruentForMorphisms( endo, ObjectAttributesAsList( Vendo )[1] );
true
gap> beta := Braiding( Vendo, Vendo );
<A morphism in Category of objects with endomorphisms>
gap> Fendo := FiberProduct( [ beta, IdentityMorphism( TensorProductOnObjects( Vendo, Vendo ) ) ] );
<An object in Category of objects with endomorphisms>
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 Ind

generated by GAPDoc2HTML