From bcb6b4dcbcdafecfdeec7b5891882b0650708ee6 Mon Sep 17 00:00:00 2001 From: Mohamed Barakat Date: Thu, 18 May 2023 14:35:39 +0200 Subject: [PATCH 1/4] use ObjectConstructor/MorphismConstructor instead of FinSet/MapOfFinSets --- gap/SkeletalFinSets.gi | 74 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/gap/SkeletalFinSets.gi b/gap/SkeletalFinSets.gi index 159bcd5..f5708fd 100644 --- a/gap/SkeletalFinSets.gi +++ b/gap/SkeletalFinSets.gi @@ -51,7 +51,7 @@ InstallMethod( CategoryOfSkeletalFinSets, end ); ## -InstallMethodForCompilerForCAP( FinSetOp, +InstallMethod( FinSetOp, [ IsCategoryOfSkeletalFinSets, IsBigInt ], function ( cat, n ) @@ -96,7 +96,7 @@ InstallMethod( MapOfFinSets, end ); ## -InstallOtherMethodForCompilerForCAP( MapOfFinSets, +InstallOtherMethod( MapOfFinSets, "for a category of skeletal finite sets, two CAP skeletal finite sets and a list", [ IsCategoryOfSkeletalFinSets, IsSkeletalFiniteSet, IsList, IsSkeletalFiniteSet ], @@ -343,7 +343,7 @@ end ); AddIdentityMorphism( SkeletalFinSets, function ( cat, n ) - return MapOfFinSets( cat, n, [ 0 .. Length( n ) - 1 ], n ); + return MorphismConstructor( cat, n, [ 0 .. Length( n ) - 1 ], n ); end ); @@ -360,7 +360,7 @@ AddPreCompose( SkeletalFinSets, cmp := List( s, i -> im_post[1 + im_pre[1 + i]] ); - return MapOfFinSets( cat, s, cmp, t ); + return MorphismConstructor( cat, s, cmp, t ); end ); @@ -368,7 +368,7 @@ end ); AddImageObject( SkeletalFinSets, function ( cat, phi ) - return FinSet( cat, BigInt( Length( Set( AsList( phi ) ) ) ) ); + return ObjectConstructor( cat, BigInt( Length( Set( AsList( phi ) ) ) ) ); end ); @@ -446,7 +446,7 @@ AddLift( SkeletalFinSets, gg := AsList( g ); ff := AsList( f ); - return MapOfFinSets( cat, S, List( S, x -> -1 + BigInt( SafePosition( gg, ff[1 + x] ) ) ), T ); + return MorphismConstructor( cat, S, List( S, x -> -1 + BigInt( SafePosition( gg, ff[1 + x] ) ) ), T ); end ); @@ -482,7 +482,7 @@ AddColift( SkeletalFinSets, return gg[SafePosition( ff, y )]; end; - return MapOfFinSets( cat, S, List( S, y -> chi(y) ), T ); + return MorphismConstructor( cat, S, List( S, y -> chi(y) ), T ); end ); @@ -490,7 +490,7 @@ end ); AddImageEmbeddingWithGivenImageObject( SkeletalFinSets, function ( cat, phi, image ) - return MapOfFinSets( cat, image, Set( AsList( phi ) ), Range( phi ) ); + return MorphismConstructor( cat, image, Set( AsList( phi ) ), Range( phi ) ); end ); @@ -507,7 +507,7 @@ AddCoastrictionToImageWithGivenImageObject( SkeletalFinSets, L := List( s, i -> -1 + BigInt( SafePosition( images, G[1 + i] ) ) ); - pi := MapOfFinSets( cat, s, L, image_object ); + pi := MorphismConstructor( cat, s, L, image_object ); #% CAP_JIT_DROP_NEXT_STATEMENT Assert( 3, IsEpimorphism( cat, pi ) ); @@ -531,7 +531,7 @@ end ); AddTerminalObject( SkeletalFinSets, function ( cat ) - return FinSet( cat, BigInt( 1 ) ); + return ObjectConstructor( cat, BigInt( 1 ) ); end ); @@ -539,7 +539,7 @@ end ); AddUniversalMorphismIntoTerminalObjectWithGivenTerminalObject( SkeletalFinSets, function ( cat, m, t ) - return MapOfFinSets( cat, m, ListWithIdenticalEntries( Length( m ), BigInt( 0 ) ), t ); + return MorphismConstructor( cat, m, ListWithIdenticalEntries( Length( m ), BigInt( 0 ) ), t ); end ); @@ -547,7 +547,7 @@ end ); AddDirectProduct( SkeletalFinSets, function ( cat, L ) - return FinSet( cat, Product( List( L, Length ) ) ); + return ObjectConstructor( cat, Product( List( L, Length ) ) ); end ); @@ -562,7 +562,7 @@ AddProjectionInFactorOfDirectProductWithGivenDirectProduct( SkeletalFinSets, a := Product( List( D{[ 1 .. k - 1 ]}, Length ) ); - return MapOfFinSets( cat, P, List( P, i -> RemInt( QuoInt( i, a ), l ) ), T ); + return MorphismConstructor( cat, P, List( P, i -> RemInt( QuoInt( i, a ), l ) ), T ); end ); @@ -580,7 +580,7 @@ AddUniversalMorphismIntoDirectProductWithGivenDirectProduct( SkeletalFinSets, taus := List( tau, AsList ); # if l = 0, then Sum( [ 0 .. l - 1 ], j -> ... ) = 0 ∈ TerminalObject = P - return MapOfFinSets( cat, T, List( T, i -> Sum( [ 0 .. l - 1 ], j -> taus[1 + j][1 + i] * dd[1 + j] ) ), P ); + return MorphismConstructor( cat, T, List( T, i -> Sum( [ 0 .. l - 1 ], j -> taus[1 + j][1 + i] * dd[1 + j] ) ), P ); end ); @@ -593,7 +593,7 @@ AddEqualizer( SkeletalFinSets, Eq := Filtered( [ 0 .. Length( s ) - 1 ], x -> ForAll( [ 1 .. Length( D ) - 1 ], j -> D2[j][1 + x] = D2[j + 1][1 + x] ) ); - return FinSet( cat, Length( Eq ) ); + return ObjectConstructor( cat, Length( Eq ) ); end ); @@ -606,7 +606,7 @@ AddEmbeddingOfEqualizerWithGivenEqualizer( SkeletalFinSets, Eq := Filtered( [ 0 .. Length( s ) - 1 ], x -> ForAll( [ 1 .. Length( D ) - 1 ], j -> D2[j][1 + x] = D2[j + 1][1 + x] ) ); - return MapOfFinSets( cat, E, Eq, s ); + return MorphismConstructor( cat, E, Eq, s ); end ); @@ -621,7 +621,7 @@ AddUniversalMorphismIntoEqualizerWithGivenEqualizer( SkeletalFinSets, t := AsList( tau ); - return MapOfFinSets( cat, test_object, List( test_object, x -> -1 + BigInt( SafePosition( Eq, t[1 + x] ) ) ), E ); + return MorphismConstructor( cat, test_object, List( test_object, x -> -1 + BigInt( SafePosition( Eq, t[1 + x] ) ) ), E ); end ); @@ -640,7 +640,7 @@ end ); AddInitialObject( SkeletalFinSets, function ( cat ) - return FinSet( cat, BigInt( 0 ) ); + return ObjectConstructor( cat, BigInt( 0 ) ); end ); @@ -648,7 +648,7 @@ end ); AddUniversalMorphismFromInitialObjectWithGivenInitialObject( SkeletalFinSets, function ( cat, m, I ) - return MapOfFinSets( cat, I, [ ], m ); + return MorphismConstructor( cat, I, [ ], m ); end ); @@ -692,7 +692,7 @@ end ); AddMonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject( SkeletalFinSets, function ( cat, M, injective_object ) - return MapOfFinSets( cat, M, [ 0 .. Length( M ) - 1 ], injective_object ); + return MorphismConstructor( cat, M, [ 0 .. Length( M ) - 1 ], injective_object ); end ); @@ -700,7 +700,7 @@ end ); AddCoproduct( SkeletalFinSets, function ( cat, L ) - return FinSet( cat, Sum( List( L, Length ) ) ); + return ObjectConstructor( cat, Sum( List( L, Length ) ) ); end ); @@ -715,7 +715,7 @@ AddInjectionOfCofactorOfCoproductWithGivenCoproduct( SkeletalFinSets, s := L[i]; - return MapOfFinSets( cat, s, [ sum .. sum + Length( s ) - 1 ], coproduct ); + return MorphismConstructor( cat, s, [ sum .. sum + Length( s ) - 1 ], coproduct ); end ); @@ -726,7 +726,7 @@ AddUniversalMorphismFromCoproductWithGivenCoproduct( SkeletalFinSets, concat := Concatenation( List( tau, AsList ) ); - return MapOfFinSets( cat, S, concat, test_object ); + return MorphismConstructor( cat, S, concat, test_object ); end ); @@ -734,7 +734,7 @@ end ); AddCoequalizer( SkeletalFinSets, function ( cat, s, D ) - return FinSet( cat, BigInt( Length( SKELETAL_FIN_SETS_ExplicitCoequalizer( s, D ) ) ) ); + return ObjectConstructor( cat, BigInt( Length( SKELETAL_FIN_SETS_ExplicitCoequalizer( s, D ) ) ) ); end ); @@ -747,7 +747,7 @@ AddProjectionOntoCoequalizerWithGivenCoequalizer( SkeletalFinSets, cmp := List( s, x -> -1 + BigInt( SafeUniquePositionProperty( Cq, c -> x in c ) ) ); - return MapOfFinSets( cat, s, cmp, C ); + return MorphismConstructor( cat, s, cmp, C ); end ); @@ -758,7 +758,7 @@ AddUniversalMorphismFromCoequalizerWithGivenCoequalizer( SkeletalFinSets, Cq := SKELETAL_FIN_SETS_ExplicitCoequalizer( s, D ); - return MapOfFinSets( cat, C, List( Cq, x -> tau( x[1] ) ), Range( tau ) ); + return MorphismConstructor( cat, C, List( Cq, x -> tau( x[1] ) ), Range( tau ) ); end ); @@ -805,7 +805,7 @@ AddCartesianBraidingInverseWithGivenDirectProducts( SkeletalFinSets, n := Length( N ); - return MapOfFinSets( cat, MN, List( MN , i -> RemInt( i, n ) * m + QuoInt( i, n ) ), NM ); + return MorphismConstructor( cat, MN, List( MN , i -> RemInt( i, n ) * m + QuoInt( i, n ) ), NM ); end ); @@ -817,7 +817,7 @@ AddExponentialOnObjects( SkeletalFinSets, m := Length( M ); n := Length( N ); - return FinSet( cat, n ^ m ); + return ObjectConstructor( cat, n ^ m ); end ); @@ -831,7 +831,7 @@ AddCartesianLambdaElimination( SkeletalFinSets, v := AsList( intro )[1]; - return MapOfFinSets( cat, + return MorphismConstructor( cat, M, List( [ 0 .. m - 1 ], i -> RemInt( QuoInt( v, n^i ), n ) ), N ); @@ -850,7 +850,7 @@ AddCartesianLambdaIntroduction( SkeletalFinSets, images := AsList( map ); - return MapOfFinSets( cat, + return MorphismConstructor( cat, TerminalObject( cat ), [ Sum( List( [ 0 .. m - 1 ], k -> images[1 + k] * n^k ) ) ], ExponentialOnObjects( cat, M, N ) ); @@ -864,7 +864,7 @@ AddExactCoverWithGlobalElements( SkeletalFinSets, T := TerminalObject( cat ); - return List( [ 0 .. Length( A ) - 1 ], i -> MapOfFinSets( cat, T, [ i ], A ) ); + return List( [ 0 .. Length( A ) - 1 ], i -> MorphismConstructor( cat, T, [ i ], A ) ); end ); @@ -880,7 +880,7 @@ AddExponentialOnMorphismsWithGivenExponentials( SkeletalFinSets, mors := ExactCoverWithGlobalElements( cat, MN ); - return MapOfFinSets( cat, + return MorphismConstructor( cat, S, List( mors, mor -> AsList( CartesianLambdaIntroduction( cat, @@ -911,7 +911,7 @@ AddCartesianEvaluationMorphismWithGivenSource( SkeletalFinSets, exp := n ^ m; - return MapOfFinSets( cat, HM_NxM, List( [ 0 .. ( n^m * m ) - 1 ], i -> RemInt( QuoInt( i, n^QuoInt( i, exp ) ), n ) ), N ); + return MorphismConstructor( cat, HM_NxM, List( [ 0 .. ( n^m * m ) - 1 ], i -> RemInt( QuoInt( i, n^QuoInt( i, exp ) ), n ) ), N ); end ); @@ -925,9 +925,9 @@ AddCartesianCoevaluationMorphismWithGivenRange( SkeletalFinSets, mn := m * n; - #return MapOfFinSets( cat, M, List( [ 0 .. m - 1 ], i -> Sum( [ 0 .. n - 1 ], j -> ( i + m * j ) * (m*n)^j ) ), HN_MxN ); + #return MorphismConstructor( cat, M, List( [ 0 .. m - 1 ], i -> Sum( [ 0 .. n - 1 ], j -> ( i + m * j ) * (m*n)^j ) ), HN_MxN ); - return MapOfFinSets( cat, M, List( [ 0 .. m - 1 ], i -> i * GeometricSum( mn, n ) + m * mn * GeometricSumDiff1( mn, n ) ), HN_MxN ); + return MorphismConstructor( cat, M, List( [ 0 .. m - 1 ], i -> i * GeometricSum( mn, n ) + m * mn * GeometricSumDiff1( mn, n ) ), HN_MxN ); end ); @@ -935,7 +935,7 @@ end ); AddSubobjectClassifier( SkeletalFinSets, function ( cat ) - return FinSet( cat, BigInt( 2 ) ); + return ObjectConstructor( cat, BigInt( 2 ) ); end ); @@ -959,7 +959,7 @@ AddClassifyingMorphismOfSubobjectWithGivenSubobjectClassifier( SkeletalFinSets, end ); - return MapOfFinSets( cat, range, chi, Omega ); + return MorphismConstructor( cat, range, chi, Omega ); end ); From a0decc0e5e1e392aaa2b47a0896048bc1dd03a08 Mon Sep 17 00:00:00 2001 From: Mohamed Barakat Date: Fri, 19 May 2023 23:05:44 +0200 Subject: [PATCH 2/4] converted logic templates into logic functions Co-authored-by: Fabian Zickgraf --- gap/CompilerLogic.gi | 90 ++++++++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 24 deletions(-) diff --git a/gap/CompilerLogic.gi b/gap/CompilerLogic.gi index 3de50c7..955fb3b 100644 --- a/gap/CompilerLogic.gi +++ b/gap/CompilerLogic.gi @@ -85,6 +85,72 @@ CapJitAddLogicFunction( function ( tree ) end ); +## list{[ ]} => [ ] +CapJitAddLogicFunction( function ( tree ) + local pre_func; + + Info( InfoCapJit, 1, "####" ); + Info( InfoCapJit, 1, "Apply logic for extracting the empty sublist of a given list" ); + + pre_func := + function ( tree, additional_arguments ) + local args; + + if CapJitIsCallToGlobalFunction( tree, "{}" ) then + + args := tree.args; + + if args.2.type = "EXPR_LIST" and args.2.list.length = 0 and IsBound( args.1.data_type ) then + + return rec( type := "EXPR_LIST", list := AsSyntaxTreeList( [ ] ), data_type := args.1.data_type ); + + fi; + + fi; + + return tree; + + end; + + return CapJitIterateOverTree( tree, pre_func, CapJitResultFuncCombineChildren, ReturnTrue, true ); + +end ); + +## Product( [ ] ) => BigInt( 1 ) and Product( [ ], func ) => BigInt( 1 ) +CapJitAddLogicFunction( function ( tree ) + local pre_func; + + Info( InfoCapJit, 1, "####" ); + Info( InfoCapJit, 1, "Apply logic for computing the empty product of an empty list of integers" ); + + pre_func := + function ( tree, additional_arguments ) + local args, is_big_int, values; + + if CapJitIsCallToGlobalFunction( tree, "Product" ) then + + args := tree.args; + + if args.1.type = "EXPR_LIST" and args.1.list.length = 0 and IsBound( args.1.data_type ) then + + return rec( type := "EXPR_FUNCCALL", + funcref := rec( + gvar := "BigInt", + type := "EXPR_REF_GVAR" ), + args := rec( 1 := rec( type := "EXPR_INT", value := 1 ), length := 1, type := "SYNTAX_TREE_LIST" ) ); + + fi; + + fi; + + return tree; + + end; + + return CapJitIterateOverTree( tree, pre_func, CapJitResultFuncCombineChildren, ReturnTrue, true ); + +end ); + ## Teach CompilerForCAP about the input type of the function so it can correctly type the function, ## that can be done with the following code (adapted from the existing List type signature): ## @@ -260,14 +326,6 @@ CapJitAddLogicTemplate( ) ); -CapJitAddLogicTemplate( - rec( - variable_names := [ "list" ], - src_template := "list{[ ]}", - dst_template := "[ ]", - ) -); - CapJitAddLogicTemplate( rec( variable_names := [ "list" ], @@ -284,22 +342,6 @@ CapJitAddLogicTemplate( ) ); -CapJitAddLogicTemplate( - rec( - variable_names := [ ], - src_template := "Product( [ ] )", - dst_template := "BigInt( 1 )", - ) -); - -CapJitAddLogicTemplate( - rec( - variable_names := [ "func" ], - src_template := "Product( [ ], func )", - dst_template := "BigInt( 1 )", - ) -); - CapJitAddLogicTemplate( rec( variable_names := [ "entry" ], From 0fafabb97c4f2b30a70bcb9953c75658dc3133ca Mon Sep 17 00:00:00 2001 From: Mohamed Barakat Date: Sat, 20 May 2023 16:58:47 +0200 Subject: [PATCH 3/4] renamed IsSkeletalFiniteSet(Map) -> IsObject/MorphismInCategoryOfSkeletalFinSets --- gap/CompilerLogic.gi | 4 ++-- gap/Julia.gi | 2 +- gap/SkeletalFinSets.gd | 32 ++++++++++++++++---------------- gap/SkeletalFinSets.gi | 34 +++++++++++++++++----------------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/gap/CompilerLogic.gi b/gap/CompilerLogic.gi index 955fb3b..8102680 100644 --- a/gap/CompilerLogic.gi +++ b/gap/CompilerLogic.gi @@ -154,7 +154,7 @@ end ); ## Teach CompilerForCAP about the input type of the function so it can correctly type the function, ## that can be done with the following code (adapted from the existing List type signature): ## -CapJitAddTypeSignature( "List", [ IsSkeletalFiniteSet, IsFunction ], function ( args, func_stack ) +CapJitAddTypeSignature( "List", [ IsObjectInCategoryOfSkeletalFinSets, IsFunction ], function ( args, func_stack ) args := ShallowCopy( args ); @@ -175,7 +175,7 @@ end ); CapJitAddLogicTemplate( rec( variable_names := [ "M", "func" ], - variable_filters := [ IsSkeletalFiniteSet, IsObject ], + variable_filters := [ IsObjectInCategoryOfSkeletalFinSets, IsObject ], src_template := "List( M, func )", dst_template := "List( [ 0 .. Length( M ) - 1 ], func )", ) diff --git a/gap/Julia.gi b/gap/Julia.gi index ef26785..8b1e543 100644 --- a/gap/Julia.gi +++ b/gap/Julia.gi @@ -33,7 +33,7 @@ end ); ## InstallMethod( MapOfFinSets, - [ IsSkeletalFiniteSet, IsJuliaObject, IsSkeletalFiniteSet ], + [ IsObjectInCategoryOfSkeletalFinSets, IsJuliaObject, IsObjectInCategoryOfSkeletalFinSets ], function ( source, graph, range ) diff --git a/gap/SkeletalFinSets.gd b/gap/SkeletalFinSets.gd index 17fe281..6279abe 100644 --- a/gap/SkeletalFinSets.gd +++ b/gap/SkeletalFinSets.gd @@ -19,14 +19,14 @@ DeclareCategory( "IsCategoryOfSkeletalFinSets", #! The GAP category of objects in the category #! of skeletal finite sets. #! @Arguments object -DeclareCategory( "IsSkeletalFiniteSet", +DeclareCategory( "IsObjectInCategoryOfSkeletalFinSets", IsCapCategoryObject ); #! @Description #! The GAP category of morphisms in the category #! of skeletal finite sets. #! @Arguments object -DeclareCategory( "IsSkeletalFiniteSetMap", +DeclareCategory( "IsMorphismInCategoryOfSkeletalFinSets", IsCapCategoryMorphism ); #! @Section Attributes @@ -37,9 +37,9 @@ DeclareCategory( "IsSkeletalFiniteSetMap", #! @Arguments M #! @Returns an integer DeclareAttribute( "Length", - IsSkeletalFiniteSet ); + IsObjectInCategoryOfSkeletalFinSets ); -CapJitAddTypeSignature( "Length", [ IsSkeletalFiniteSet ], IsBigInt ); +CapJitAddTypeSignature( "Length", [ IsObjectInCategoryOfSkeletalFinSets ], IsBigInt ); #! @Description #! The list associated to a skeletal finite set, i.e., @@ -47,18 +47,18 @@ CapJitAddTypeSignature( "Length", [ IsSkeletalFiniteSet ], IsBigInt ); #! @Arguments M #! @Returns a list DeclareAttribute( "AsList", - IsSkeletalFiniteSet ); + IsObjectInCategoryOfSkeletalFinSets ); -CapJitAddTypeSignature( "AsList", [ IsSkeletalFiniteSet ], rec( filter := IsList, element_type := rec( filter := IsBigInt ) ) ); +CapJitAddTypeSignature( "AsList", [ IsObjectInCategoryOfSkeletalFinSets ], rec( filter := IsList, element_type := rec( filter := IsBigInt ) ) ); #! @Description -#! The graph defining the skeletal finite set morphism phi, see . +#! The graph defining the skeletal finite set morphism phi, see . #! @Arguments phi #! @Returns a list DeclareAttribute( "AsList", - IsSkeletalFiniteSetMap ); + IsMorphismInCategoryOfSkeletalFinSets ); -CapJitAddTypeSignature( "AsList", [ IsSkeletalFiniteSetMap ], rec( filter := IsList, element_type := rec( filter := IsBigInt ) ) ); +CapJitAddTypeSignature( "AsList", [ IsMorphismInCategoryOfSkeletalFinSets ], rec( filter := IsList, element_type := rec( filter := IsBigInt ) ) ); #! @Section Constructors @@ -97,7 +97,7 @@ KeyDependentOperation( "FinSet", IsCategoryOfSkeletalFinSets, IsBigInt, ReturnTr #! @Arguments s, G, t #! @Returns a &CAP; morphism DeclareOperation( "MapOfFinSets", - [ IsSkeletalFiniteSet, IsList, IsSkeletalFiniteSet ] ); + [ IsObjectInCategoryOfSkeletalFinSets, IsList, IsObjectInCategoryOfSkeletalFinSets ] ); #! @InsertChunk SkeletalMapOfFinSets #! @Section Tools @@ -107,7 +107,7 @@ DeclareOperation( "MapOfFinSets", #! @Arguments s, f #! @Returns a list DeclareOperation( "ListOp", - [ IsSkeletalFiniteSet, IsFunction ] ); + [ IsObjectInCategoryOfSkeletalFinSets, IsFunction ] ); #! @Description #! Construct the embedding $\iota:$s$\to$t of the finite sets s and t, @@ -115,34 +115,34 @@ DeclareOperation( "ListOp", #! @Arguments s, t #! @Returns a &CAP; morphism DeclareOperation( "EmbeddingOfFinSets", - [ IsSkeletalFiniteSet, IsSkeletalFiniteSet ] ); + [ IsObjectInCategoryOfSkeletalFinSets, IsObjectInCategoryOfSkeletalFinSets ] ); #! @Description #! Compute the Preimage of t under the morphism phi. #! @Arguments phi, t #! @Returns a &CAP; object DeclareOperation( "Preimage", - [ IsSkeletalFiniteSetMap, IsList ] ); + [ IsMorphismInCategoryOfSkeletalFinSets, IsList ] ); #! @Description #! Compute the image of s_ under the morphism phi. #! @Arguments phi, s_ #! @Returns a &CAP; object DeclareOperation( "ImageObject", - [ IsSkeletalFiniteSetMap, IsSkeletalFiniteSet ] ); + [ IsMorphismInCategoryOfSkeletalFinSets, IsObjectInCategoryOfSkeletalFinSets ] ); #! @Description #! Returns the image of L[1] under the map phi assuming L[1] is a nonnegative integer smaller than Length( Source( phi ) ). #! @Arguments phi, L #! @Returns a list # DeclareOperation( "CallFuncList", -# [ IsSkeletalFiniteSetMap, IsList ] ); +# [ IsMorphismInCategoryOfSkeletalFinSets, IsList ] ); # Technical functions DeclareGlobalFunction( "INSTALL_FUNCTIONS_FOR_SKELETAL_FIN_SETS" ); DeclareGlobalFunction( "SKELETAL_FIN_SETS_ExplicitCoequalizer" ); -CapJitAddTypeSignature( "SKELETAL_FIN_SETS_ExplicitCoequalizer", [ IsSkeletalFiniteSet, IsList ], rec( filter := IsList, element_type := rec( filter := IsList, element_type := rec( filter := IsBigInt ) ) ) ); +CapJitAddTypeSignature( "SKELETAL_FIN_SETS_ExplicitCoequalizer", [ IsObjectInCategoryOfSkeletalFinSets, IsList ], rec( filter := IsList, element_type := rec( filter := IsList, element_type := rec( filter := IsBigInt ) ) ) ); DeclareGlobalFunction( "SKELETAL_FIN_SETS_IsMonomorphism" ); CapJitAddTypeSignature( "SKELETAL_FIN_SETS_IsMonomorphism", [ IsList, IsBigInt ], IsBool ); diff --git a/gap/SkeletalFinSets.gi b/gap/SkeletalFinSets.gi index f5708fd..87331a6 100644 --- a/gap/SkeletalFinSets.gi +++ b/gap/SkeletalFinSets.gi @@ -13,7 +13,7 @@ InstallMethod( CategoryOfSkeletalFinSets, cat := CreateCapCategoryWithDataTypes( "SkeletalFinSets", IsCategoryOfSkeletalFinSets, - IsSkeletalFiniteSet, IsSkeletalFiniteSetMap, IsCapCategoryTwoCell, + IsObjectInCategoryOfSkeletalFinSets, IsMorphismInCategoryOfSkeletalFinSets, IsCapCategoryTwoCell, IsBigInt, rec( filter := IsList, element_type := rec( filter := IsBigInt ) ), fail ); @@ -63,7 +63,7 @@ end ); ## InstallMethod( AsList, "for a CAP skeletal finite set", - [ IsSkeletalFiniteSet ], + [ IsObjectInCategoryOfSkeletalFinSets ], function ( s ) @@ -74,7 +74,7 @@ end ); ## InstallMethod( ListOp, "for a CAP skeletal finite set and a function", - [ IsSkeletalFiniteSet, IsFunction ], + [ IsObjectInCategoryOfSkeletalFinSets, IsFunction ], function ( s, f ) @@ -87,7 +87,7 @@ end ); ## InstallMethod( MapOfFinSets, "for two CAP skeletal finite sets and a list", - [ IsSkeletalFiniteSet, IsList, IsSkeletalFiniteSet ], + [ IsObjectInCategoryOfSkeletalFinSets, IsList, IsObjectInCategoryOfSkeletalFinSets ], function ( s, G, t ) @@ -98,7 +98,7 @@ end ); ## InstallOtherMethod( MapOfFinSets, "for a category of skeletal finite sets, two CAP skeletal finite sets and a list", - [ IsCategoryOfSkeletalFinSets, IsSkeletalFiniteSet, IsList, IsSkeletalFiniteSet ], + [ IsCategoryOfSkeletalFinSets, IsObjectInCategoryOfSkeletalFinSets, IsList, IsObjectInCategoryOfSkeletalFinSets ], function ( cat, s, G, t ) @@ -109,7 +109,7 @@ end ); ## InstallMethod( EmbeddingOfFinSets, "for two CAP skeletal finite sets", - [ IsSkeletalFiniteSet, IsSkeletalFiniteSet ], + [ IsObjectInCategoryOfSkeletalFinSets, IsObjectInCategoryOfSkeletalFinSets ], function ( s, t ) local iota; @@ -126,7 +126,7 @@ end ); ## InstallMethod( Preimage, "for a CAP map of skeletal finite sets and a CAP skeletal finite set", - [ IsSkeletalFiniteSetMap, IsList ], + [ IsMorphismInCategoryOfSkeletalFinSets, IsList ], function ( phi, t ) local S; @@ -142,7 +142,7 @@ end ); ## InstallMethod( ImageObject, "for a CAP map of skeletal finite sets and a CAP skeletal finite set", - [ IsSkeletalFiniteSetMap, IsSkeletalFiniteSet ], + [ IsMorphismInCategoryOfSkeletalFinSets, IsObjectInCategoryOfSkeletalFinSets ], function ( phi, s_ ) return ImageObject( PreCompose( EmbeddingOfFinSets( s_, Source( phi ) ), phi ) ); @@ -152,7 +152,7 @@ end ); ## InstallMethod( CallFuncList, "for a CAP map of skeletal finite sets and a list", - [ IsSkeletalFiniteSetMap, IsList ], + [ IsMorphismInCategoryOfSkeletalFinSets, IsList ], function ( phi, L ) local x; @@ -988,7 +988,7 @@ end ); ## InstallMethod( String, "for a CAP skeletal finite set", - [ IsSkeletalFiniteSet ], + [ IsObjectInCategoryOfSkeletalFinSets ], function ( s ) return Concatenation( "FinSet( SkeletalFinSets, ", String( Length( s ) ), " )" ); @@ -997,7 +997,7 @@ end ); ## InstallMethod( String, "for a CAP map of skeletal finite sets", - [ IsSkeletalFiniteSetMap ], + [ IsMorphismInCategoryOfSkeletalFinSets ], function ( phi ) return Concatenation( "MapOfFinSets( SkeletalFinSets, ", String( Source( phi ) ), ", ", String( AsList( phi ) ), ", ", String( Range( phi ) ), " )" ); @@ -1006,7 +1006,7 @@ end ); ## InstallMethod( ViewString, "for a CAP skeletal finite set", - [ IsSkeletalFiniteSet ], + [ IsObjectInCategoryOfSkeletalFinSets ], function ( s ) return Concatenation( "|", String( Length( s ) ), "|" ); @@ -1015,7 +1015,7 @@ end ); ## InstallMethod( ViewString, "for a CAP map of skeletal finite sets", - [ IsSkeletalFiniteSetMap ], + [ IsMorphismInCategoryOfSkeletalFinSets ], function ( phi ) local arrow; @@ -1049,7 +1049,7 @@ end ); ## InstallMethod( PrintString, "for a CAP skeletal finite set", - [ IsSkeletalFiniteSet ], + [ IsObjectInCategoryOfSkeletalFinSets ], function ( s ) local l, string; @@ -1073,7 +1073,7 @@ end ); ## InstallMethod( PrintString, "for a CAP map of skeletal finite sets", - [ IsSkeletalFiniteSetMap ], + [ IsMorphismInCategoryOfSkeletalFinSets ], function ( phi ) @@ -1087,7 +1087,7 @@ end ); ## InstallMethod( DisplayString, "for a CAP skeletal finite set", - [ IsSkeletalFiniteSet ], + [ IsObjectInCategoryOfSkeletalFinSets ], function ( s ) @@ -1098,7 +1098,7 @@ end ); ## InstallMethod( DisplayString, "for a CAP map of skeletal finite sets", - [ IsSkeletalFiniteSetMap ], + [ IsMorphismInCategoryOfSkeletalFinSets ], function ( phi ) From 30c9d082f299b24a5076919601b1655c33b81e8f Mon Sep 17 00:00:00 2001 From: Mohamed Barakat Date: Sun, 14 May 2023 20:14:46 +0200 Subject: [PATCH 4/4] functional --- ...etalFinSetsWithMorphismsGivenByFunctions.g | 55 + ...SkeletalFinSetsWithMorphismsGivenByLists.g | 7 +- examples/SkeletalWellDefined.g | 4 - gap/CompilerLogic.gi | 124 ++ gap/SkeletalFinSets.gd | 58 +- gap/SkeletalFinSets.gi | 466 +++++--- gap/SkeletalFinSetsEager.gd | 64 ++ gap/SkeletalFinSetsEager.gi | 282 +++++ gap/init.gi | 8 +- ...ithMorphismsGivenByFunctionsPrecompiled.gi | 1016 +++++++++++++++++ ...etsWithMorphismsGivenByListsPrecompiled.gi | 287 +++-- init.g | 2 + read.g | 4 + 13 files changed, 2088 insertions(+), 289 deletions(-) create mode 100644 examples/PrecompileCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions.g create mode 100644 gap/SkeletalFinSetsEager.gd create mode 100644 gap/SkeletalFinSetsEager.gi create mode 100644 gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled.gi diff --git a/examples/PrecompileCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions.g b/examples/PrecompileCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions.g new file mode 100644 index 0000000..bedded4 --- /dev/null +++ b/examples/PrecompileCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions.g @@ -0,0 +1,55 @@ +#! @Chapter Precompilation + +#! @Section Precompiling the category of skeletal finite sets + +#! @Example + +#! #@if ValueOption( "no_precompiled_code" ) <> true + +LoadPackage( "FinSetsForCAP", false ); +#! true +LoadPackage( "CompilerForCAP", false ); +#! true + +ReadPackageOnce( "FinSetsForCAP", "gap/CompilerLogic.gi" ); +#! true + +category_constructor := + {} -> CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions( );; +given_arguments := [ ];; +compiled_category_name := + "CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled";; +package_name := "FinSetsForCAP";; +primitive_operations := + ListPrimitivelyInstalledOperationsOfCategory( + category_constructor( : no_precompiled_code := true ) );; +list_of_operations := + SortedList( Concatenation( primitive_operations, [ + #"HasPushoutComplement", + "PushoutComplement", + ] ) );; + +CapJitPrecompileCategoryAndCompareResult( + category_constructor, + given_arguments, + package_name, + compiled_category_name + : operations := list_of_operations, + number_of_objectified_objects_in_data_structure_of_object := 1, + number_of_objectified_morphisms_in_data_structure_of_object := 0, + number_of_objectified_objects_in_data_structure_of_morphism := 2, + number_of_objectified_morphisms_in_data_structure_of_morphism := 1 +);; + +CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled( ); +#! SkeletalFinSets + +cat := CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions( ); +#! SkeletalFinSets + +cat!.precompiled_functions_added; +#! true + +#! #@fi + +#! @EndExample diff --git a/examples/PrecompileCategoryOfSkeletalFinSetsWithMorphismsGivenByLists.g b/examples/PrecompileCategoryOfSkeletalFinSetsWithMorphismsGivenByLists.g index 900c6e3..5e2ae6a 100644 --- a/examples/PrecompileCategoryOfSkeletalFinSetsWithMorphismsGivenByLists.g +++ b/examples/PrecompileCategoryOfSkeletalFinSetsWithMorphismsGivenByLists.g @@ -11,10 +11,11 @@ LoadPackage( "FinSetsForCAP", false ); LoadPackage( "CompilerForCAP", false ); #! true -ReadPackage( "FinSetsForCAP", "gap/CompilerLogic.gi" ); +ReadPackageOnce( "FinSetsForCAP", "gap/CompilerLogic.gi" ); #! true -category_constructor := {} -> CategoryOfSkeletalFinSets( );; +category_constructor := + {} -> CategoryOfSkeletalFinSetsWithMorphismsGivenByLists( );; given_arguments := [ ];; compiled_category_name := "CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled";; @@ -43,7 +44,7 @@ CapJitPrecompileCategoryAndCompareResult( CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled( ); #! SkeletalFinSets -cat := CategoryOfSkeletalFinSets( ); +cat := CategoryOfSkeletalFinSetsWithMorphismsGivenByLists( ); #! SkeletalFinSets cat!.precompiled_functions_added; diff --git a/examples/SkeletalWellDefined.g b/examples/SkeletalWellDefined.g index 506574a..6f53fa8 100644 --- a/examples/SkeletalWellDefined.g +++ b/examples/SkeletalWellDefined.g @@ -7,10 +7,6 @@ s := FinSet( 7 ); #! |7| t := FinSet( 4 ); #! |4| -psi := MapOfFinSets( s, [ 0, 2, 1, 2, 1, 3 ], t ); -#! |7| → |4| -IsWellDefined( psi ); -#! false psi := MapOfFinSets( s, [ 0, 2, 1, 2, 1, 3, -2 ], t ); #! |7| → |4| IsWellDefined( psi ); diff --git a/gap/CompilerLogic.gi b/gap/CompilerLogic.gi index 8102680..c23dc45 100644 --- a/gap/CompilerLogic.gi +++ b/gap/CompilerLogic.gi @@ -116,6 +116,51 @@ CapJitAddLogicFunction( function ( tree ) end ); +## [ entry1, ... ]{[ ]} => [ ] +CapJitAddLogicFunction( function ( tree ) + local pre_func; + + Info( InfoCapJit, 1, "####" ); + Info( InfoCapJit, 1, "Apply logic for extracting the empty sublist of a given list" ); + + pre_func := + function ( tree, additional_arguments ) + local args, is_big_int, values; + + if CapJitIsCallToGlobalFunction( tree, "{}" ) then + + args := tree.args; + + if args.2.type = "EXPR_LIST" and args.2.list.length = 0 then + + if IsBound( args.1.list ) and IsBound( args.1.list.1 ) then + + if IsBound( args.1.list.1.data_type ) then + return rec( type := "EXPR_LIST", list := AsSyntaxTreeList( [ ] ), data_type := args.1.list.1.data_type ); + elif IsBound( args.1.list.1.funcref ) and IsBound( args.1.list.1.funcref.data_type ) then + return rec( type := "EXPR_LIST", list := AsSyntaxTreeList( [ ] ), data_type := args.1.list.1.funcref.data_type.signature[2] ); + elif IsBound( args.1.list.1.funcref ) and CapJitIsCallToGlobalFunction( args.1.list.1, "Length" ) then + return rec( type := "EXPR_LIST", list := AsSyntaxTreeList( [ ] ), data_type := rec( filter := IsInt ) ); + fi; + + elif CapJitIsCallToGlobalFunction( args.1, "ListWithIdenticalEntries" ) then + + return rec( type := "EXPR_LIST", list := AsSyntaxTreeList( [ ] ), data_type := args.1.args.2.funcref.data_type.signature[2] ); + + fi; + + fi; + + fi; + + return tree; + + end; + + return CapJitIterateOverTree( tree, pre_func, CapJitResultFuncCombineChildren, ReturnTrue, true ); + +end ); + ## Product( [ ] ) => BigInt( 1 ) and Product( [ ], func ) => BigInt( 1 ) CapJitAddLogicFunction( function ( tree ) local pre_func; @@ -171,6 +216,15 @@ CapJitAddTypeSignature( "List", [ IsObjectInCategoryOfSkeletalFinSets, IsFunctio end ); +## +CapJitAddLogicTemplate( + rec( + variable_names := [ "list" ], + src_template := "List( list, ID_FUNC )", + dst_template := "list", + ) +); + ## CapJitAddLogicTemplate( rec( @@ -326,6 +380,15 @@ CapJitAddLogicTemplate( ) ); +CapJitAddLogicTemplate( + rec( + variable_names := [ "number1", "number2" ], + variable_filters := [ IsBigInt, IsBigInt ], + src_template := "REM_INT( REM_INT( number1, number2 ), number2 )", + dst_template := "REM_INT( number1, number2 )", + ) +); + CapJitAddLogicTemplate( rec( variable_names := [ "list" ], @@ -382,6 +445,14 @@ CapJitAddLogicTemplate( ) ); +CapJitAddLogicTemplate( + rec( + variable_names := [ "entry" ], + src_template := "ListWithIdenticalEntries( BigInt( 1 ), entry )", + dst_template := "[ entry ]", + ) +); + CapJitAddLogicTemplate( rec( variable_names := [ "length", "constant", "pos" ], @@ -467,3 +538,56 @@ CapJitAddLogicTemplate( dst_template := "entry in list", ) ); + +CapJitAddLogicTemplate( + rec( + variable_names := [ "map" ], + variable_filters := [ IsMorphismInCategoryOfSkeletalFinSets ], + src_template := "List( [ 0 .. Length( Source( map ) ) - 1 ], i -> AsList( map )[1 + i] )", + dst_template := "AsList( map )", + ) +); + +CapJitAddLogicTemplate( + rec( + variable_names := [ "map" ], + variable_filters := [ IsMorphismInCategoryOfSkeletalFinSets ], + src_template := "AsList( map ){[ 1 .. Length( Source( map ) ) ]}", + dst_template := "AsList( map )", + ) +); + +CapJitAddLogicTemplate( + rec( + variable_names := [ "list", "number" ], + variable_filters := [ IsList, IsBigInt ], + src_template := "List( [ 0 .. number - 1 ], i -> list[1 + i] )", + dst_template := "list{[ 1 .. number ]}", + ) +); + +CapJitAddLogicTemplate( + rec( + variable_names := [ "length", "offset" ], + variable_filters := [ IsBigInt, IsBigInt ], + src_template := "List( [ 0 .. length - 1 ], i -> offset + i )", + dst_template := "[ offset .. offset + length - 1 ]", + ) +); + +CapJitAddLogicTemplate( + rec( + variable_names := [ "length" ], + variable_filters := [ IsBigInt ], + src_template := "Length( [ 0 .. length - 1 ] )", + dst_template := "length", + ) +); + +CapJitAddLogicTemplate( + rec( + variable_names := [ "list", "index", "x" ], + src_template := "List( list, map -> ( i -> AsList( map )[1 + i] ) )[index]( x )", + dst_template := "List( list, AsList )[index][1 + x]", + ) +); diff --git a/gap/SkeletalFinSets.gd b/gap/SkeletalFinSets.gd index 6279abe..75a314d 100644 --- a/gap/SkeletalFinSets.gd +++ b/gap/SkeletalFinSets.gd @@ -29,6 +29,27 @@ DeclareCategory( "IsObjectInCategoryOfSkeletalFinSets", DeclareCategory( "IsMorphismInCategoryOfSkeletalFinSets", IsCapCategoryMorphism ); +#! @Description +#! The GAP category of categories +#! of skeletal finite sets with morphisms given by functions. +#! @Arguments object +DeclareCategory( "IsCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions", + IsCategoryOfSkeletalFinSets ); + +#! @Description +#! The GAP category of objects in the category +#! of skeletal finite sets with morphisms given by functions. +#! @Arguments object +DeclareCategory( "IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions", + IsObjectInCategoryOfSkeletalFinSets ); + +#! @Description +#! The GAP category of morphisms in the category +#! of skeletal finite sets with morphisms given by functions. +#! @Arguments object +DeclareCategory( "IsMorphismInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions", + IsMorphismInCategoryOfSkeletalFinSets ); + #! @Section Attributes #! @Description @@ -52,13 +73,23 @@ DeclareAttribute( "AsList", CapJitAddTypeSignature( "AsList", [ IsObjectInCategoryOfSkeletalFinSets ], rec( filter := IsList, element_type := rec( filter := IsBigInt ) ) ); #! @Description -#! The graph defining the skeletal finite set morphism phi, see . +#! The function defining the skeletal finite set morphism phi, see . #! @Arguments phi -#! @Returns a list -DeclareAttribute( "AsList", +#! @Returns a function +DeclareAttribute( "AsFunc", IsMorphismInCategoryOfSkeletalFinSets ); -CapJitAddTypeSignature( "AsList", [ IsMorphismInCategoryOfSkeletalFinSets ], rec( filter := IsList, element_type := rec( filter := IsBigInt ) ) ); +BindGlobal( "SkeletalFinSets_func_type", + rec( filter := IsFunction, signature := [ [ rec( filter := IsBigInt ) ], rec( filter := IsBigInt ) ] ) ); + +CapJitAddTypeSignature( "AsFunc", [ IsMorphismInCategoryOfSkeletalFinSets ], SkeletalFinSets_func_type ); + +#! @Description +#! The list of images defining the skeletal finite set morphism phi, see . +#! @Arguments phi +#! @Returns a list +DeclareAttribute( "ListOfImages", + IsMorphismInCategoryOfSkeletalFinSets ); #! @Section Constructors @@ -72,6 +103,16 @@ DeclareOperation( "CategoryOfSkeletalFinSets", [ ] ); #! It is automatically created while loading this package. DeclareGlobalName( "SkeletalFinSets" ); +#! @Description +#! Construct a category of skeletal finite sets with maps given by functions. +#! @Returns a &CAP; category +DeclareOperation( "CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions", [ ] ); + +#! @Description +#! The default instance of the category of skeletal finite sets given by functions. +#! It is automatically created while loading this package. +DeclareGlobalName( "SkeletalFinSetsWithMorphismsGivenByFunctions" ); + #! @Description #! Construct a skeletal finite set residing in #! the default instance of the category of skeletal finite sets SkeletalFinSets @@ -92,13 +133,12 @@ KeyDependentOperation( "FinSet", IsCategoryOfSkeletalFinSets, IsBigInt, ReturnTr #! @Description #! Construct a map $\phi:$s$\to$t of the skeletal finite sets s and t, -#! i.e., a morphism in the &CAP; category of s, where G -#! is a list of integers in t describing the graph of $\phi$. -#! @Arguments s, G, t +#! i.e., a morphism in the &CAP; category of s, where f +#! is a function with values in t describing the graph of $\phi$. +#! @Arguments s, f, t #! @Returns a &CAP; morphism DeclareOperation( "MapOfFinSets", - [ IsObjectInCategoryOfSkeletalFinSets, IsList, IsObjectInCategoryOfSkeletalFinSets ] ); -#! @InsertChunk SkeletalMapOfFinSets + [ IsObjectInCategoryOfSkeletalFinSets, IsFunction, IsObjectInCategoryOfSkeletalFinSets ] ); #! @Section Tools diff --git a/gap/SkeletalFinSets.gi b/gap/SkeletalFinSets.gi index 87331a6..3fea877 100644 --- a/gap/SkeletalFinSets.gi +++ b/gap/SkeletalFinSets.gi @@ -5,17 +5,21 @@ # ## -InstallMethod( CategoryOfSkeletalFinSets, - [ ], - +InstallMethod( CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions, + "for no input", + [ ], + function ( ) local cat; - cat := CreateCapCategoryWithDataTypes( - "SkeletalFinSets", IsCategoryOfSkeletalFinSets, - IsObjectInCategoryOfSkeletalFinSets, IsMorphismInCategoryOfSkeletalFinSets, IsCapCategoryTwoCell, - IsBigInt, rec( filter := IsList, element_type := rec( filter := IsBigInt ) ), fail - ); + cat := CreateCapCategoryWithDataTypes( "SkeletalFinSets", + IsCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions, + IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions, + IsMorphismInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions, + IsCapCategoryTwoCell, + IsBigInt, + SkeletalFinSets_func_type, + fail ); cat!.category_as_first_argument := true; @@ -40,7 +44,7 @@ InstallMethod( CategoryOfSkeletalFinSets, if ValueOption( "no_precompiled_code" ) <> true then - ADD_FUNCTIONS_FOR_CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled( cat ); + ADD_FUNCTIONS_FOR_CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled( cat ); fi; @@ -84,25 +88,59 @@ end ); ## Morphisms +## +InstallOtherMethodForCompilerForCAP( ListOfImages, + "for a category of skeletal finite sets and a CAP map of skeletal finite sets", + [ IsCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions, IsMorphismInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions ], + + function ( cat, map ) + + return List( [ 0 .. Length( Source( map ) ) - 1 ], AsFunc( map ) ); + +end ); + +## +InstallMethod( AsList, + "for a CAP map of skeletal finite sets", + [ IsMorphismInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions ], + + function ( map ) + local L; + + L := ListOfImages( CapCategory( map ), map ); + + if Length( L ) > 1 and First( L ) + 1 = L[2] and First( L ) < Last( L ) then + ConvertToRangeRep( L ); + fi; + + return L; + +end ); + ## InstallMethod( MapOfFinSets, - "for two CAP skeletal finite sets and a list", - [ IsObjectInCategoryOfSkeletalFinSets, IsList, IsObjectInCategoryOfSkeletalFinSets ], + "for two CAP skeletal finite sets and a function", + [ IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions, IsFunction, IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions ], - function ( s, G, t ) + function ( s, f, t ) - return MapOfFinSets( CapCategory( s ), s, G, t ); + return MorphismConstructor( CapCategory( s ), s, f, t ); end ); ## InstallOtherMethod( MapOfFinSets, - "for a category of skeletal finite sets, two CAP skeletal finite sets and a list", - [ IsCategoryOfSkeletalFinSets, IsObjectInCategoryOfSkeletalFinSets, IsList, IsObjectInCategoryOfSkeletalFinSets ], + "for two CAP skeletal finite sets and a list", + [ IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions, IsList, IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions ], - function ( cat, s, G, t ) + function ( s, G, t ) + local f; - return MorphismConstructor( cat, s, G, t ); + f := CapJitTypedExpression( + i -> G[1 + i], + cat -> SkeletalFinSets_func_type ); + + return MapOfFinSets( s, f, t ); end ); @@ -129,13 +167,13 @@ InstallMethod( Preimage, [ IsMorphismInCategoryOfSkeletalFinSets, IsList ], function ( phi, t ) - local S; + local S, f; S := AsList( Source( phi ) ); - phi := AsList( phi ); + f := AsFunc( phi ); - return Filtered( S, i -> phi[1 + i] in t ); + return Filtered( S, i -> f( i ) in t ); end ); @@ -159,7 +197,7 @@ InstallMethod( CallFuncList, x := L[1]; - return AsList( phi )[1 + x]; + return AsFunc( phi )( x ); end ); @@ -264,13 +302,13 @@ end ); ## AddMorphismConstructor( SkeletalFinSets, - function ( cat, source, images, range ) + function ( cat, source, func, range ) local map; map := CreateCapCategoryMorphismWithAttributes( cat, - source, - range, - AsList, images ); + source, + range, + AsFunc, func ); #% CAP_JIT_DROP_NEXT_STATEMENT Assert( 4, IsWellDefined( map ) ); @@ -283,7 +321,7 @@ end ); AddMorphismDatum( SkeletalFinSets, function ( cat, map ) - return AsList( map ); + return AsFunc( map ); end ); @@ -302,20 +340,22 @@ end ); ## AddIsWellDefinedForMorphisms( SkeletalFinSets, function ( cat, mor ) - local s, rel, t; + local s, f, t; s := Length( Source( mor ) ); - rel := AsList( mor ); + f := AsFunc( mor ); t := Length( Range( mor ) ); ## For CompilerForCAP we need if-elif-else with the same structure - if not ForAll( rel, a -> IsBigInt( a ) and a >= 0 ) then - return false; - elif s <> Length( rel ) then - return false; - elif not ForAll( rel, a -> a < t ) then + if not ForAll( [ 0 .. s - 1 ], + function( x ) + local fx; + fx := f( x ); + return IsBigInt( fx ) and fx >= 0 and fx < t; + end ) then + return false; else return true; @@ -326,8 +366,12 @@ end ); ## AddIsEqualForMorphisms( SkeletalFinSets, function ( cat, mor1, mor2 ) + local f1, f2; + + f1 := AsFunc( mor1 ); + f2 := AsFunc( mor2 ); - return AsList( mor1 ) = AsList( mor2 ); + return ForAll( [ 0 .. Length( Source( mor1 ) ) - 1 ], x -> f1( x ) = f2( x ) ); end ); @@ -342,25 +386,32 @@ end ); ## AddIdentityMorphism( SkeletalFinSets, function ( cat, n ) + local f; + + f := CapJitTypedExpression( + IdFunc, + cat -> SkeletalFinSets_func_type ); - return MorphismConstructor( cat, n, [ 0 .. Length( n ) - 1 ], n ); + return MorphismConstructor( cat, n, f, n ); end ); ## AddPreCompose( SkeletalFinSets, function ( cat, map_pre, map_post ) - local s, t, im_pre, im_post, cmp; + local s, t, pre, post, pre_post; s := Source( map_pre ); t := Range( map_post ); - im_pre := AsList( map_pre ); - im_post := AsList( map_post ); + pre := AsFunc( map_pre ); + post := AsFunc( map_post ); - cmp := List( s, i -> im_post[1 + im_pre[1 + i]] ); + pre_post := CapJitTypedExpression( + i -> post( pre( i ) ), + cat -> SkeletalFinSets_func_type ); - return MorphismConstructor( cat, s, cmp, t ); + return MorphismConstructor( cat, s, pre_post, t ); end ); @@ -368,7 +419,7 @@ end ); AddImageObject( SkeletalFinSets, function ( cat, phi ) - return ObjectConstructor( cat, BigInt( Length( Set( AsList( phi ) ) ) ) ); + return ObjectConstructor( cat, BigInt( Length( Set( ListOfImages( cat, phi ) ) ) ) ); end ); @@ -378,7 +429,7 @@ AddIsEpimorphism( SkeletalFinSets, function ( cat, phi ) local imgs, t; - imgs := AsList( phi ); + imgs := ListOfImages( cat, phi ); t := Length( Range( phi ) ); @@ -399,7 +450,7 @@ AddIsMonomorphism( SkeletalFinSets, function ( cat, phi ) local imgs, t; - imgs := AsList( phi ); + imgs := ListOfImages( cat, phi ); t := Length( Range( phi ) ); @@ -422,8 +473,8 @@ AddIsLiftable( SkeletalFinSets, function ( cat, f, g ) local ff, gg, fff; - ff := AsList( f ); - gg := AsList( g ); + ff := ListOfImages( cat, f ); + gg := ListOfImages( cat, g ); if 100 * Length( ff ) < Length( gg ) then fff := Set( ff ); @@ -438,15 +489,19 @@ end ); ## AddLift( SkeletalFinSets, function ( cat, f, g ) - local S, T, gg, ff; + local S, T, gg, ff, chi; S := Source( f ); T := Source( g ); - gg := AsList( g ); - ff := AsList( f ); + gg := ListOfImages( cat, g ); + ff := AsFunc( f ); - return MorphismConstructor( cat, S, List( S, x -> -1 + BigInt( SafePosition( gg, ff[1 + x] ) ) ), T ); + chi := CapJitTypedExpression( + x -> -1 + BigInt( SafePosition( gg, ff( x ) ) ), + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, S, chi, T ); end ); @@ -456,8 +511,8 @@ AddIsColiftable( SkeletalFinSets, function ( cat, f, g ) local ff, gg; - ff := AsList( f ); - gg := AsList( g ); + ff := ListOfImages( cat, f ); + gg := ListOfImages( cat, g ); return ForAll( Set( ff ), i -> Length( Set( gg{Positions( ff, i )} ) ) = 1 ); @@ -466,15 +521,15 @@ end ); ## AddColift( SkeletalFinSets, function ( cat, f, g ) - local S, T, ff, gg, chi; + local S, T, ff, gg, c, chi; S := Range( f ); T := Range( g ); - ff := AsList( f ); - gg := AsList( g ); + ff := ListOfImages( cat, f ); + gg := ListOfImages( cat, g ); - chi := + c := function ( y ) if not y in ff then return BigInt( 0 ); @@ -482,32 +537,45 @@ AddColift( SkeletalFinSets, return gg[SafePosition( ff, y )]; end; - return MorphismConstructor( cat, S, List( S, y -> chi(y) ), T ); + chi := CapJitTypedExpression( + c, + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, S, chi, T ); end ); ## AddImageEmbeddingWithGivenImageObject( SkeletalFinSets, function ( cat, phi, image ) + local images, f; + + images := Set( ListOfImages( cat, phi ) ); + + f := CapJitTypedExpression( + i -> images[1 + i], + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, image, f, Range( phi ) ); - return MorphismConstructor( cat, image, Set( AsList( phi ) ), Range( phi ) ); - end ); ## AddCoastrictionToImageWithGivenImageObject( SkeletalFinSets, function ( cat, phi, image_object ) - local G, images, s, L, l, pi; + local G, images, s, f, l, pi; - G := AsList( phi ); + G := ListOfImages( cat, phi ); images := Set( G ); s := Source( phi ); - L := List( s, i -> -1 + BigInt( SafePosition( images, G[1 + i] ) ) ); + f := CapJitTypedExpression( + i -> -1 + BigInt( SafePosition( images, G[1 + i] ) ), + cat -> SkeletalFinSets_func_type ); - pi := MorphismConstructor( cat, s, L, image_object ); + pi := MorphismConstructor( cat, s, f, image_object ); #% CAP_JIT_DROP_NEXT_STATEMENT Assert( 3, IsEpimorphism( cat, pi ) ); @@ -538,8 +606,15 @@ end ); ## AddUniversalMorphismIntoTerminalObjectWithGivenTerminalObject( SkeletalFinSets, function ( cat, m, t ) + local zero, f; + + zero := BigInt( 0 ); - return MorphismConstructor( cat, m, ListWithIdenticalEntries( Length( m ), BigInt( 0 ) ), t ); + f := CapJitTypedExpression( + i -> zero, + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, m, f, t ); end ); @@ -554,7 +629,7 @@ end ); ## AddProjectionInFactorOfDirectProductWithGivenDirectProduct( SkeletalFinSets, function ( cat, D, k, P ) - local T, l, a; + local T, l, a, f; T := D[k]; @@ -562,14 +637,18 @@ AddProjectionInFactorOfDirectProductWithGivenDirectProduct( SkeletalFinSets, a := Product( List( D{[ 1 .. k - 1 ]}, Length ) ); - return MorphismConstructor( cat, P, List( P, i -> RemInt( QuoInt( i, a ), l ) ), T ); + f := CapJitTypedExpression( + i -> RemInt( QuoInt( i, a ), l ), + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, P, f, T ); end ); ## AddUniversalMorphismIntoDirectProductWithGivenDirectProduct( SkeletalFinSets, function ( cat, D, T, tau, P ) - local l, d, dd, taus; + local l, d, dd, taus, f; l := Length( D ); @@ -577,21 +656,25 @@ AddUniversalMorphismIntoDirectProductWithGivenDirectProduct( SkeletalFinSets, dd := List( [ 0 .. l - 1 ], j -> Product( d{[ 1 .. j ]} ) ); - taus := List( tau, AsList ); + taus := List( tau, AsFunc ); + + f := CapJitTypedExpression( + # if l = 0, then Sum( [ 0 .. l - 1 ], j -> ... ) = 0 ∈ TerminalObject = P + i -> Sum( [ 0 .. l - 1 ], j -> dd[1 + j] * taus[1 + j]( i ) ), + cat -> SkeletalFinSets_func_type ); - # if l = 0, then Sum( [ 0 .. l - 1 ], j -> ... ) = 0 ∈ TerminalObject = P - return MorphismConstructor( cat, T, List( T, i -> Sum( [ 0 .. l - 1 ], j -> taus[1 + j][1 + i] * dd[1 + j] ) ), P ); + return MorphismConstructor( cat, T, f, P ); end ); ## AddEqualizer( SkeletalFinSets, function ( cat, s, D ) - local D2, Eq; + local funcs, Eq; - D2 := List( D, AsList ); + funcs := List( D, AsFunc ); - Eq := Filtered( [ 0 .. Length( s ) - 1 ], x -> ForAll( [ 1 .. Length( D ) - 1 ], j -> D2[j][1 + x] = D2[j + 1][1 + x] ) ); + Eq := Filtered( [ 0 .. Length( s ) - 1 ], i -> ForAll( [ 1 .. Length( D ) - 1 ], j -> funcs[j]( i ) = funcs[j + 1]( i ) ) ); return ObjectConstructor( cat, Length( Eq ) ); @@ -600,28 +683,36 @@ end ); ## AddEmbeddingOfEqualizerWithGivenEqualizer( SkeletalFinSets, function ( cat, s, D, E ) - local D2, Eq; + local funcs, Eq, f; - D2 := List( D, AsList ); + funcs := List( D, AsFunc ); - Eq := Filtered( [ 0 .. Length( s ) - 1 ], x -> ForAll( [ 1 .. Length( D ) - 1 ], j -> D2[j][1 + x] = D2[j + 1][1 + x] ) ); + Eq := Filtered( [ 0 .. Length( s ) - 1 ], x -> ForAll( [ 1 .. Length( D ) - 1 ], j -> funcs[j]( x ) = funcs[j + 1]( x ) ) ); - return MorphismConstructor( cat, E, Eq, s ); + f := CapJitTypedExpression( + i -> Eq[1 + i], + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, E, f, s ); end ); ## AddUniversalMorphismIntoEqualizerWithGivenEqualizer( SkeletalFinSets, function ( cat, s, D, test_object, tau, E ) - local D2, Eq, t; + local funcs, Eq, t, f; + + funcs := List( D, AsFunc ); - D2 := List( D, AsList ); + Eq := Filtered( [ 0 .. Length( s ) - 1 ], x -> ForAll( [ 1 .. Length( D ) - 1 ], j -> funcs[j]( x ) = funcs[j + 1]( x ) ) ); - Eq := Filtered( [ 0 .. Length( s ) - 1 ], x -> ForAll( [ 1 .. Length( D ) - 1 ], j -> D2[j][1 + x] = D2[j + 1][1 + x] ) ); + t := AsFunc( tau ); - t := AsList( tau ); + f := CapJitTypedExpression( + x -> -1 + BigInt( SafePosition( Eq, t( x ) ) ), + cat -> SkeletalFinSets_func_type ); - return MorphismConstructor( cat, test_object, List( test_object, x -> -1 + BigInt( SafePosition( Eq, t[1 + x] ) ) ), E ); + return MorphismConstructor( cat, test_object, f, E ); end ); @@ -647,8 +738,13 @@ end ); ## AddUniversalMorphismFromInitialObjectWithGivenInitialObject( SkeletalFinSets, function ( cat, m, I ) + local f; - return MorphismConstructor( cat, I, [ ], m ); + f := CapJitTypedExpression( + IdFunc, + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, I, f, m ); end ); @@ -691,8 +787,13 @@ end ); ## AddMonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject( SkeletalFinSets, function ( cat, M, injective_object ) + local f; + + f := CapJitTypedExpression( + IdFunc, + cat -> SkeletalFinSets_func_type ); - return MorphismConstructor( cat, M, [ 0 .. Length( M ) - 1 ], injective_object ); + return MorphismConstructor( cat, M, f, injective_object ); end ); @@ -707,7 +808,7 @@ end ); ## AddInjectionOfCofactorOfCoproductWithGivenCoproduct( SkeletalFinSets, function ( cat, L, i, coproduct ) - local O, sum, s; + local O, sum, s, f; O := L{[ 1 .. i - 1 ]}; @@ -715,18 +816,41 @@ AddInjectionOfCofactorOfCoproductWithGivenCoproduct( SkeletalFinSets, s := L[i]; - return MorphismConstructor( cat, s, [ sum .. sum + Length( s ) - 1 ], coproduct ); + f := CapJitTypedExpression( + i -> sum + i, + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, s, f, coproduct ); end ); ## AddUniversalMorphismFromCoproductWithGivenCoproduct( SkeletalFinSets, function ( cat, L, test_object, tau, S ) - local concat; + local sources, sums, funcs, interval, c, f; + + sources := List( tau, map -> Length( Source( map ) ) ); + + ## FIXME: make a functional loop if possible + sums := List( [ 0 .. Length( tau ) ], k -> Sum( sources{[ 1 .. k ]} ) ); - concat := Concatenation( List( tau, AsList ) ); + funcs := List( tau, AsFunc ); - return MorphismConstructor( cat, S, concat, test_object ); + interval := [ 1 .. Length( tau ) ]; + + c := + function( i ) + local p; + ## FIXME: PositionSorted + p := SafePositionProperty( interval, k -> i < sums[k + 1] ); + return funcs[p]( i - sums[p] ); + end; + + f := CapJitTypedExpression( + c, + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, S, f, test_object ); end ); @@ -741,24 +865,32 @@ end ); ## AddProjectionOntoCoequalizerWithGivenCoequalizer( SkeletalFinSets, function ( cat, s, D, C ) - local Cq, cmp; + local Cq, f; Cq := SKELETAL_FIN_SETS_ExplicitCoequalizer( s, D ); - cmp := List( s, x -> -1 + BigInt( SafeUniquePositionProperty( Cq, c -> x in c ) ) ); + f := CapJitTypedExpression( + i -> -1 + BigInt( SafeUniquePositionProperty( Cq, c -> i in c ) ), + cat -> SkeletalFinSets_func_type ); - return MorphismConstructor( cat, s, cmp, C ); + return MorphismConstructor( cat, s, f, C ); end ); ## AddUniversalMorphismFromCoequalizerWithGivenCoequalizer( SkeletalFinSets, function ( cat, s, D, test_object, tau, C ) - local Cq; + local Cq, func, f; Cq := SKELETAL_FIN_SETS_ExplicitCoequalizer( s, D ); - return MorphismConstructor( cat, C, List( Cq, x -> tau( x[1] ) ), Range( tau ) ); + func := AsFunc( tau ); + + f := CapJitTypedExpression( + i -> func( Cq[1 + i][1] ), + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, C, f, Range( tau ) ); end ); @@ -799,13 +931,17 @@ end ); ## AddCartesianBraidingInverseWithGivenDirectProducts( SkeletalFinSets, function ( cat, MN, M, N, NM ) - local m, n; + local m, n, f; m := Length( M ); n := Length( N ); - return MorphismConstructor( cat, MN, List( MN , i -> RemInt( i, n ) * m + QuoInt( i, n ) ), NM ); + f := CapJitTypedExpression( + i -> RemInt( i, n ) * m + QuoInt( i, n ), + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, MN, f, NM ); end ); @@ -824,35 +960,40 @@ end ); ## InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism AddCartesianLambdaElimination( SkeletalFinSets, function ( cat, M, N, intro ) - local m, n, v; + local m, n, v, f; m := Length( M ); n := Length( N ); - v := AsList( intro )[1]; + v := AsFunc( intro )( 0 ); - return MorphismConstructor( cat, - M, - List( [ 0 .. m - 1 ], i -> RemInt( QuoInt( v, n^i ), n ) ), - N ); + f := CapJitTypedExpression( + i -> RemInt( QuoInt( v, n^i ), n ), + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, M, f, N ); end ); ## InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure AddCartesianLambdaIntroduction( SkeletalFinSets, function ( cat, map ) - local M, m, N, n, images; + local M, m, N, n, func, f; M := Source( map ); m := Length( M ); N := Range( map ); n := Length( N ); - images := AsList( map ); + func := AsFunc( map ); + + f := CapJitTypedExpression( + i -> Sum( List( [ 0 .. m - 1 ], k -> func( k ) * n^k ) ), + cat -> SkeletalFinSets_func_type ); return MorphismConstructor( cat, TerminalObject( cat ), - [ Sum( List( [ 0 .. m - 1 ], k -> images[1 + k] * n^k ) ) ], + f, ExponentialOnObjects( cat, M, N ) ); end ); @@ -864,38 +1005,49 @@ AddExactCoverWithGlobalElements( SkeletalFinSets, T := TerminalObject( cat ); - return List( [ 0 .. Length( A ) - 1 ], i -> MorphismConstructor( cat, T, [ i ], A ) ); + return List( [ 0 .. Length( A ) - 1 ], j -> + MorphismConstructor( cat, + T, + CapJitTypedExpression( + i -> j, + cat -> SkeletalFinSets_func_type ), + A ) ); end ); ## AddExponentialOnMorphismsWithGivenExponentials( SkeletalFinSets, function ( cat, S, alpha, beta, T ) - local M, N, MN, mors; + local M, N, D, MN, f; M := Range( alpha ); N := Source( beta ); - MN := ExponentialOnObjects( cat, M, N ); - - mors := ExactCoverWithGlobalElements( cat, MN ); + D := TerminalObject( cat ); - return MorphismConstructor( cat, - S, - List( mors, mor -> - AsList( CartesianLambdaIntroduction( cat, - PreComposeList( - cat, - [ alpha, - CartesianLambdaElimination( cat, - M, - N, - mor ), - beta ] ) ) )[1 + 0] ), - T ); + MN := ExponentialOnObjects( cat, M, N ); -end, 1 + Sum( [ [ "ExponentialOnObjects", 1 ], - [ "ExactCoverWithGlobalElements", 1 ], + f := CapJitTypedExpression( + i -> AsFunc( CartesianLambdaIntroduction( cat, + PreComposeList( + cat, + [ alpha, + CartesianLambdaElimination( cat, + M, + N, + MorphismConstructor( cat, + D, + CapJitTypedExpression( + j -> i, + cat -> SkeletalFinSets_func_type ), + MN ) ), + beta ] ) ) )( 0 ), + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, S, f, T ); + +end, 1 + Sum( [ [ "TerminalObject", 1 ], + [ "ExponentialOnObjects", 1 ], [ "PreComposeList", 2 ], [ "CartesianLambdaElimination", 2 ], [ "CartesianLambdaIntroduction", 2 ] ], @@ -904,30 +1056,40 @@ end, 1 + Sum( [ [ "ExponentialOnObjects", 1 ], ## AddCartesianEvaluationMorphismWithGivenSource( SkeletalFinSets, function ( cat, M, N, HM_NxM ) - local m, n, exp; + local m, n, exp, f; m := Length( M ); n := Length( N ); exp := n ^ m; - return MorphismConstructor( cat, HM_NxM, List( [ 0 .. ( n^m * m ) - 1 ], i -> RemInt( QuoInt( i, n^QuoInt( i, exp ) ), n ) ), N ); + f := CapJitTypedExpression( + i -> RemInt( QuoInt( i, n^QuoInt( i, exp ) ), n ), + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, HM_NxM, f, N ); end ); ## AddCartesianCoevaluationMorphismWithGivenRange( SkeletalFinSets, function ( cat, M, N, HN_MxN ) - local m, n, mn; + local m, n, mn, f; m := Length( M ); n := Length( N ); mn := m * n; - #return MorphismConstructor( cat, M, List( [ 0 .. m - 1 ], i -> Sum( [ 0 .. n - 1 ], j -> ( i + m * j ) * (m*n)^j ) ), HN_MxN ); + #f := CapJitTypedExpression( + # i -> Sum( [ 0 .. n - 1 ], j -> ( i + m * j ) * (m*n)^j ), + # cat -> SkeletalFinSets_func_type ); + + f := CapJitTypedExpression( + i -> i * GeometricSum( mn, n ) + m * mn * GeometricSumDiff1( mn, n ), + cat -> SkeletalFinSets_func_type ); - return MorphismConstructor( cat, M, List( [ 0 .. m - 1 ], i -> i * GeometricSum( mn, n ) + m * mn * GeometricSumDiff1( mn, n ) ), HN_MxN ); + return MorphismConstructor( cat, M, f, HN_MxN ); end ); @@ -942,25 +1104,28 @@ end ); ## AddClassifyingMorphismOfSubobjectWithGivenSubobjectClassifier( SkeletalFinSets, function ( cat, monomorphism, Omega ) - local range, images, chi; + local range, images, c, chi; range := Range( monomorphism ); - images := AsList( monomorphism ); - - chi := List( range, - function ( x ) - - if x in images then - return BigInt( 1 ); - fi; - - return BigInt( 0 ); - - end ); - - return MorphismConstructor( cat, range, chi, Omega ); - + images := ListOfImages( cat, monomorphism ); + + c := + function ( x ) + if x in images then + return BigInt( 1 ); + fi; + + return BigInt( 0 ); + + end; + + chi := CapJitTypedExpression( + c, + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( cat, range, chi, Omega ); + end ); ## @@ -1105,14 +1270,3 @@ InstallMethod( DisplayString, return Concatenation( PrintString( phi ), "\n" ); end ); - -## -InstallOtherMethod( FinSet, - "for a nonnegative integer", - [ IsBigInt ], - - function ( n ) - - return FinSet( SkeletalFinSets, n ); - -end ); diff --git a/gap/SkeletalFinSetsEager.gd b/gap/SkeletalFinSetsEager.gd new file mode 100644 index 0000000..785d3e3 --- /dev/null +++ b/gap/SkeletalFinSetsEager.gd @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# FinSetsForCAP: The elementary topos of (skeletal) finite sets +# +# Declarations +# + +#! @Chapter The category of skeletal finite sets with morphisms given by lists + +#! @Section GAP Categories + +#! @Description +#! The GAP category of categories +#! of skeletal finite sets with morphisms given by lists. +#! @Arguments object +DeclareCategory( "IsCategoryOfSkeletalFinSetsWithMorphismsGivenByLists", + IsCategoryOfSkeletalFinSets ); + +#! @Description +#! The GAP category of objects in the category +#! of skeletal finite sets with morphisms given by lists. +#! @Arguments object +DeclareCategory( "IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByLists", + IsObjectInCategoryOfSkeletalFinSets ); + +#! @Description +#! The GAP category of morphisms in the category +#! of skeletal finite sets with morphisms given by lists. +#! @Arguments object +DeclareCategory( "IsMorphismInCategoryOfSkeletalFinSetsWithMorphismsGivenByLists", + IsMorphismInCategoryOfSkeletalFinSets ); + +#! @Section Attributes + +#! @Description +#! The list of images defining the skeletal finite set morphism phi, see . +#! @Arguments phi +#! @Returns a list +DeclareAttribute( "AsList", + IsMorphismInCategoryOfSkeletalFinSets ); + +CapJitAddTypeSignature( "AsList", [ IsMorphismInCategoryOfSkeletalFinSetsWithMorphismsGivenByLists ], + rec( filter := IsList, element_type := rec( filter := IsBigInt ) ) ); + +#! @Section Constructors + +#! @Description +#! Construct a category of skeletal finite sets with maps given by lists. +#! @Returns a &CAP; category +DeclareOperation( "CategoryOfSkeletalFinSetsWithMorphismsGivenByLists", [ ] ); + +#! @Description +#! The default instance of the category of skeletal finite sets given by lists. +#! It is automatically created while loading this package. +DeclareGlobalName( "SkeletalFinSetsWithMorphismsGivenByLists" ); + +#! @Description +#! Construct a map $\phi:$s$\to$t of the skeletal finite sets s and t, +#! i.e., a morphism in the &CAP; category of s, where list_of_images +#! is a list of integers in t describing the images of $\phi$. +#! @Arguments s, list_of_images, t +#! @Returns a &CAP; morphism +DeclareOperation( "MapOfFinSets", + [ IsObjectInCategoryOfSkeletalFinSets, IsList, IsObjectInCategoryOfSkeletalFinSets ] ); +#! @InsertChunk SkeletalMapOfFinSets diff --git a/gap/SkeletalFinSetsEager.gi b/gap/SkeletalFinSetsEager.gi new file mode 100644 index 0000000..4427ab6 --- /dev/null +++ b/gap/SkeletalFinSetsEager.gi @@ -0,0 +1,282 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# FinSetsForCAP: The elementary topos of (skeletal) finite sets +# +# Implementations +# + +## +InstallMethod( CategoryOfSkeletalFinSetsWithMorphismsGivenByLists, + "for no input", + [ ], + + function ( ) + local object_constructor, object_datum, + morphism_constructor, morphism_datum, + skeletal_finsets_with_morphisms_given_by_functions, + modeling_tower_object_constructor, modeling_tower_object_datum, + modeling_tower_morphism_constructor, modeling_tower_morphism_datum, + skeletal_finsets_with_morphisms_given_by_lists; + + ## + object_constructor := function( cat, cardinality ) + + return CreateCapCategoryObjectWithAttributes( cat, + Length, cardinality ); + + end; + + ## + object_datum := { cat, obj } -> Length( obj ); + + ## + morphism_constructor := function( cat, source, list_of_images, range ) + + return CreateCapCategoryMorphismWithAttributes( cat, + source, + range, + AsList, list_of_images ); + + end; + + ## + morphism_datum := { cat, mor } -> AsList( mor ); + + ## building the categorical tower: + skeletal_finsets_with_morphisms_given_by_functions := + CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions( : FinalizeCategory := true ); + + ## from the raw object data to the object in the modeling category + modeling_tower_object_constructor := + function( cat, cardinality ) + local skeletal_finsets_with_morphisms_given_by_functions; + + skeletal_finsets_with_morphisms_given_by_functions := ModelingCategory( cat ); + + return ObjectConstructor( skeletal_finsets_with_morphisms_given_by_functions, + cardinality ); + + end; + + ## from the object in the modeling category to the raw object data + modeling_tower_object_datum := { cat, obj } -> Length( obj ); + + ## from the raw morphism data to the morphism in the modeling category + modeling_tower_morphism_constructor := + function( cat, source, list_of_images, range ) + local skeletal_finsets_with_morphisms_given_by_functions, f; + + skeletal_finsets_with_morphisms_given_by_functions := ModelingCategory( cat ); + + f := CapJitTypedExpression( + i -> list_of_images[1 + i], + cat -> SkeletalFinSets_func_type ); + + return MorphismConstructor( skeletal_finsets_with_morphisms_given_by_functions, + source, + f, + range ); + + end; + + ## from the morphism in the modeling category to the raw morphism data + modeling_tower_morphism_datum := + function( cat, mor ) + + return List( [ 0 .. Length( Source( mor ) ) - 1 ], AsFunc( mor ) ); + + end; + + skeletal_finsets_with_morphisms_given_by_lists := + ReinterpretationOfCategory( skeletal_finsets_with_morphisms_given_by_functions, + rec( name := "SkeletalFinSets", + category_filter := IsCategoryOfSkeletalFinSetsWithMorphismsGivenByLists, + category_object_filter := IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByLists, + category_morphism_filter := IsMorphismInCategoryOfSkeletalFinSetsWithMorphismsGivenByLists, + object_constructor := object_constructor, + object_datum := object_datum, + morphism_constructor := morphism_constructor, + morphism_datum := morphism_datum, + modeling_tower_object_constructor := modeling_tower_object_constructor, + modeling_tower_object_datum := modeling_tower_object_datum, + modeling_tower_morphism_constructor := modeling_tower_morphism_constructor, + modeling_tower_morphism_datum := modeling_tower_morphism_datum, + only_primitive_operations := true, + ) : FinalizeCategory := false ); + + # this is a workhorse category -> no logic and caching only via IsIdenticalObj + CapCategorySwitchLogicOff( skeletal_finsets_with_morphisms_given_by_lists ); + + SetRangeCategoryOfHomomorphismStructure( skeletal_finsets_with_morphisms_given_by_lists, skeletal_finsets_with_morphisms_given_by_lists ); + SetIsEquippedWithHomomorphismStructure( skeletal_finsets_with_morphisms_given_by_lists, true ); + + ## + AddIsEqualForMorphisms( skeletal_finsets_with_morphisms_given_by_lists, + function ( cat, mor1, mor2 ) + + return AsList( mor1 ) = AsList( mor2 ); + + end ); + + ## the function SKELETAL_FIN_SETS_IsEpimorphism + ## has linear runtime complexity + AddIsEpimorphism( skeletal_finsets_with_morphisms_given_by_lists, + function ( cat, phi ) + local imgs, t; + + imgs := AsList( phi ); + + t := Length( Range( phi ) ); + + ## we do not have a linear purely functional test (yet), + ## the following linear runtime function works with side effects, + ## so we hide it from the compiler + + return not (false in SKELETAL_FIN_SETS_IsEpimorphism( imgs, t )); + + end ); + + ## + AddIsMonomorphism( skeletal_finsets_with_morphisms_given_by_lists, + function ( cat, phi ) + local imgs, t; + + imgs := AsList( phi ); + + t := Length( Range( phi ) ); + + ## we do not have a linear purely functional test (yet), + ## the following linear runtime function works with side effects, + ## so we hide it from the compiler + + return SKELETAL_FIN_SETS_IsMonomorphism( imgs, t ); + + end ); + + ## + AddUniversalMorphismFromCoproductWithGivenCoproduct( skeletal_finsets_with_morphisms_given_by_lists, + function ( cat, L, test_object, tau, S ) + local concat; + + concat := Concatenation( List( tau, AsList ) ); + + return MorphismConstructor( cat, S, concat, test_object ); + + end ); + + ## + AddCoequalizer( skeletal_finsets_with_morphisms_given_by_lists, + function ( cat, s, D ) + + return ObjectConstructor( cat, BigInt( Length( SKELETAL_FIN_SETS_ExplicitCoequalizer( s, D ) ) ) ); + + end ); + + ## + AddProjectionOntoCoequalizerWithGivenCoequalizer( skeletal_finsets_with_morphisms_given_by_lists, + function ( cat, s, D, C ) + local Cq, cmp; + + Cq := SKELETAL_FIN_SETS_ExplicitCoequalizer( s, D ); + + cmp := List( s, x -> -1 + BigInt( SafeUniquePositionProperty( Cq, c -> x in c ) ) ); + + return MorphismConstructor( cat, s, cmp, C ); + + end ); + + ## + AddUniversalMorphismFromCoequalizerWithGivenCoequalizer( skeletal_finsets_with_morphisms_given_by_lists, + function ( cat, s, D, test_object, tau, C ) + local Cq; + + Cq := SKELETAL_FIN_SETS_ExplicitCoequalizer( s, D ); + + return MorphismConstructor( cat, C, List( Cq, x -> tau( x[1] ) ), Range( tau ) ); + + end ); + + ## + AddExactCoverWithGlobalElements( skeletal_finsets_with_morphisms_given_by_lists, + function ( cat, A ) + local T; + + T := TerminalObject( cat ); + + return List( [ 0 .. Length( A ) - 1 ], i -> + MorphismConstructor( cat, + T, + [ i ], + A ) ); + + end ); + + ## + AddMorphismsOfExternalHom( skeletal_finsets_with_morphisms_given_by_lists, + function ( cat, A, B ) + local hom_A_B, mors; + + hom_A_B := ExponentialOnObjects( cat, A, B ); + + mors := ExactCoverWithGlobalElements( cat, hom_A_B ); + + return List( mors, + mor -> CartesianLambdaElimination( cat, + A, + B, + mor ) ); + + end, 1 + Sum( [ [ "ExponentialOnObjects", 1 ], + [ "ExactCoverWithGlobalElements", 1 ], + [ "CartesianLambdaElimination", 2 ] ], + e -> e[2] * CurrentOperationWeight( skeletal_finsets_with_morphisms_given_by_lists!.derivations_weight_list, e[1] ) ) ); + + if ValueOption( "no_precompiled_code" ) <> true then + + ADD_FUNCTIONS_FOR_CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled( skeletal_finsets_with_morphisms_given_by_lists ); + + fi; + + Finalize( skeletal_finsets_with_morphisms_given_by_lists ); + + return skeletal_finsets_with_morphisms_given_by_lists; + +end ); + +## +InstallMethod( CategoryOfSkeletalFinSets, "for no input", [ ], CategoryOfSkeletalFinSetsWithMorphismsGivenByLists ); + +## +InstallOtherMethod( FinSet, + "for a nonnegative integer", + [ IsBigInt ], + + function ( n ) + + return FinSet( SkeletalFinSets, n ); + +end ); + +## +InstallMethod( MapOfFinSets, + "for two CAP skeletal finite sets and a list", + [ IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByLists, IsList, IsObjectInCategoryOfSkeletalFinSetsWithMorphismsGivenByLists ], + + function ( s, list_of_images, t ) + + return MorphismConstructor( CapCategory( s ), s, list_of_images, t ); + +end ); + +## +InstallMethod( AsFunc, + "for a CAP map of skeletal finite sets", + [ IsMorphismInCategoryOfSkeletalFinSetsWithMorphismsGivenByLists ], + + function ( map ) + local images; + + images := AsList( map ); + + return i -> images[1 + i]; + +end ); diff --git a/gap/init.gi b/gap/init.gi index 333d2e5..b2f33d1 100644 --- a/gap/init.gi +++ b/gap/init.gi @@ -10,7 +10,13 @@ BindGlobal( "init_FinSetsForCAP", function ( ) BindGlobal( "FinSets", CategoryOfFinSets( ) ); ## - BindGlobal( "SkeletalFinSets", CategoryOfSkeletalFinSets( ) ); + BindGlobal( "SkeletalFinSetsWithMorphismsGivenByFunctions", CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions( ) ); + + ## + BindGlobal( "SkeletalFinSetsWithMorphismsGivenByLists", CategoryOfSkeletalFinSetsWithMorphismsGivenByLists( ) ); + + ## + BindGlobal( "SkeletalFinSets", SkeletalFinSetsWithMorphismsGivenByLists ); end ); diff --git a/gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled.gi b/gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled.gi new file mode 100644 index 0000000..77ced12 --- /dev/null +++ b/gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled.gi @@ -0,0 +1,1016 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# FinSetsForCAP: The elementary topos of (skeletal) finite sets +# +# Implementations +# +BindGlobal( "ADD_FUNCTIONS_FOR_CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled", function ( cat ) + + ## + AddCartesianBraidingInverseWithGivenDirectProducts( cat, + +######## +function ( cat_1, s_1, a_1, b_1, r_1 ) + local deduped_1_1, hoisted_2_1; + hoisted_2_1 := Length( a_1 ); + deduped_1_1 := Length( b_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, s_1, r_1, AsFunc, function ( i_2 ) + return REM_INT( i_2, deduped_1_1 ) * hoisted_2_1 + QUO_INT( i_2, deduped_1_1 ); + end ); +end +######## + + , 100 ); + + ## + AddCartesianCoevaluationMorphismWithGivenRange( cat, + +######## +function ( cat_1, a_1, b_1, r_1 ) + local hoisted_1_1, hoisted_2_1, deduped_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := Length( b_1 ); + deduped_4_1 := Length( a_1 ); + deduped_3_1 := deduped_4_1 * deduped_5_1; + hoisted_2_1 := deduped_4_1 * deduped_3_1 * GeometricSumDiff1( deduped_3_1, deduped_5_1 ); + hoisted_1_1 := GeometricSum( deduped_3_1, deduped_5_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, r_1, AsFunc, function ( i_2 ) + return i_2 * hoisted_1_1 + hoisted_2_1; + end ); +end +######## + + , 100 ); + + ## + AddCartesianEvaluationMorphismWithGivenSource( cat, + +######## +function ( cat_1, a_1, b_1, s_1 ) + local hoisted_1_1, deduped_3_1; + deduped_3_1 := Length( b_1 ); + hoisted_1_1 := deduped_3_1 ^ Length( a_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, s_1, b_1, AsFunc, function ( i_2 ) + return REM_INT( QUO_INT( i_2, deduped_3_1 ^ QUO_INT( i_2, hoisted_1_1 ) ), deduped_3_1 ); + end ); +end +######## + + , 100 ); + + ## + AddCartesianLambdaElimination( cat, + +######## +function ( cat_1, a_1, b_1, alpha_1 ) + local deduped_1_1, hoisted_2_1; + hoisted_2_1 := AsFunc( alpha_1 )( 0 ); + deduped_1_1 := Length( b_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, b_1, AsFunc, function ( i_2 ) + return REM_INT( QUO_INT( hoisted_2_1, deduped_1_1 ^ i_2 ), deduped_1_1 ); + end ); +end +######## + + , 100 ); + + ## + AddCartesianLambdaIntroduction( cat, + +######## +function ( cat_1, alpha_1 ) + local hoisted_1_1, hoisted_3_1, deduped_4_1, deduped_5_1; + deduped_5_1 := Length( Source( alpha_1 ) ); + deduped_4_1 := Length( Range( alpha_1 ) ); + hoisted_1_1 := AsFunc( alpha_1 ); + hoisted_3_1 := Sum( List( [ 0 .. deduped_5_1 - 1 ], function ( k_2 ) + return hoisted_1_1( k_2 ) * deduped_4_1 ^ k_2; + end ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( 1 ) ), CreateCapCategoryObjectWithAttributes( cat_1, Length, deduped_4_1 ^ deduped_5_1 ), AsFunc, function ( i_2 ) + return hoisted_3_1; + end ); +end +######## + + , 100 ); + + ## + AddCartesianLeftUnitorInverseWithGivenDirectProduct( cat, + +######## +function ( cat_1, a_1, r_1 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, a_1, AsFunc, ID_FUNC ); +end +######## + + , 100 ); + + ## + AddCartesianLeftUnitorWithGivenDirectProduct( cat, + +######## +function ( cat_1, a_1, s_1 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, a_1, AsFunc, ID_FUNC ); +end +######## + + , 100 ); + + ## + AddCartesianRightUnitorInverseWithGivenDirectProduct( cat, + +######## +function ( cat_1, a_1, r_1 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, a_1, AsFunc, ID_FUNC ); +end +######## + + , 100 ); + + ## + AddCartesianRightUnitorWithGivenDirectProduct( cat, + +######## +function ( cat_1, a_1, s_1 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, a_1, AsFunc, ID_FUNC ); +end +######## + + , 100 ); + + ## + AddClassifyingMorphismOfSubobjectWithGivenSubobjectClassifier( cat, + +######## +function ( cat_1, alpha_1, Omega_1 ) + local hoisted_1_1, hoisted_2_1; + hoisted_2_1 := BigInt( 1 ); + hoisted_1_1 := List( [ 0 .. Length( Source( alpha_1 ) ) - 1 ], AsFunc( alpha_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Range( alpha_1 ), Omega_1, AsFunc, function ( x_2 ) + if x_2 in hoisted_1_1 then + return hoisted_2_1; + else + return BigInt( 0 ); + fi; + return; + end ); +end +######## + + , 100 ); + + ## + AddCoastrictionToImageWithGivenImageObject( cat, + +######## +function ( cat_1, alpha_1, I_1 ) + local hoisted_2_1, deduped_3_1, deduped_4_1; + deduped_4_1 := Source( alpha_1 ); + deduped_3_1 := List( [ 0 .. Length( deduped_4_1 ) - 1 ], AsFunc( alpha_1 ) ); + hoisted_2_1 := SSortedList( deduped_3_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, deduped_4_1, I_1, AsFunc, function ( i_2 ) + return -1 + BigInt( SafePosition( hoisted_2_1, deduped_3_1[(1 + i_2)] ) ); + end ); +end +######## + + , 100 ); + + ## + AddCoequalizer( cat, + +######## +function ( cat_1, arg2_1, arg3_1 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( Length( SKELETAL_FIN_SETS_ExplicitCoequalizer( arg2_1, arg3_1 ) ) ) ); +end +######## + + , 100 ); + + ## + AddColift( cat, + +######## +function ( cat_1, alpha_1, beta_1 ) + local deduped_1_1, hoisted_2_1, hoisted_3_1; + hoisted_3_1 := List( [ 0 .. Length( Source( beta_1 ) ) - 1 ], AsFunc( beta_1 ) ); + hoisted_2_1 := BigInt( 0 ); + deduped_1_1 := List( [ 0 .. Length( Source( alpha_1 ) ) - 1 ], AsFunc( alpha_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Range( alpha_1 ), Range( beta_1 ), AsFunc, function ( y_2 ) + if not y_2 in deduped_1_1 then + return hoisted_2_1; + else + return hoisted_3_1[SafePosition( deduped_1_1, y_2 )]; + fi; + return; + end ); +end +######## + + , 100 ); + + ## + AddCoproduct( cat, + +######## +function ( cat_1, arg2_1 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, Sum( List( arg2_1, Length ) ) ); +end +######## + + , 100 ); + + ## + AddDirectProduct( cat, + +######## +function ( cat_1, arg2_1 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, Product( List( arg2_1, Length ) ) ); +end +######## + + , 100 ); + + ## + AddEmbeddingOfEqualizerWithGivenEqualizer( cat, + +######## +function ( cat_1, Y_1, morphisms_1, P_1 ) + local deduped_1_1, hoisted_2_1, hoisted_3_1; + hoisted_2_1 := [ 1 .. Length( morphisms_1 ) - 1 ]; + deduped_1_1 := List( morphisms_1, AsFunc ); + hoisted_3_1 := Filtered( [ 0 .. Length( Y_1 ) - 1 ], function ( x_2 ) + return ForAll( hoisted_2_1, function ( j_3 ) + return deduped_1_1[j_3]( x_2 ) = deduped_1_1[j_3 + 1]( x_2 ); + end ); + end ); + return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, Y_1, AsFunc, function ( i_2 ) + return hoisted_3_1[1 + i_2]; + end ); +end +######## + + , 100 ); + + ## + AddEpimorphismFromSomeProjectiveObject( cat, + +######## +function ( cat_1, A_1 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, A_1, A_1, AsFunc, ID_FUNC ); +end +######## + + , 100 ); + + ## + AddEqualizer( cat, + +######## +function ( cat_1, arg2_1, arg3_1 ) + local deduped_1_1, hoisted_2_1; + hoisted_2_1 := [ 1 .. Length( arg3_1 ) - 1 ]; + deduped_1_1 := List( arg3_1, AsFunc ); + return CreateCapCategoryObjectWithAttributes( cat_1, Length, Length( Filtered( [ 0 .. Length( arg2_1 ) - 1 ], function ( i_2 ) + return ForAll( hoisted_2_1, function ( j_3 ) + return deduped_1_1[j_3]( i_2 ) = deduped_1_1[j_3 + 1]( i_2 ); + end ); + end ) ) ); +end +######## + + , 100 ); + + ## + AddExactCoverWithGlobalElements( cat, + +######## +function ( cat_1, arg2_1 ) + local hoisted_1_1; + hoisted_1_1 := CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( 1 ) ); + return List( [ 0 .. Length( arg2_1 ) - 1 ], function ( j_2 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, hoisted_1_1, arg2_1, AsFunc, function ( i_3 ) + return j_2; + end ); + end ); +end +######## + + , 100 ); + + ## + AddExponentialOnMorphismsWithGivenExponentials( cat, + +######## +function ( cat_1, s_1, alpha_1, beta_1, r_1 ) + local hoisted_1_1, deduped_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1; + hoisted_5_1 := [ 0 .. Length( Source( alpha_1 ) ) - 1 ]; + hoisted_4_1 := Length( Range( beta_1 ) ); + hoisted_3_1 := AsFunc( beta_1 ); + deduped_2_1 := Length( Source( beta_1 ) ); + hoisted_1_1 := AsFunc( alpha_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, s_1, r_1, AsFunc, function ( i_2 ) + return Sum( List( hoisted_5_1, function ( k_3 ) + return hoisted_3_1( REM_INT( QUO_INT( i_2, deduped_2_1 ^ hoisted_1_1( k_3 ) ), deduped_2_1 ) ) * hoisted_4_1 ^ k_3; + end ) ); + end ); +end +######## + + , 1003 ); + + ## + AddExponentialOnObjects( cat, + +######## +function ( cat_1, a_1, b_1 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, Length( b_1 ) ^ Length( a_1 ) ); +end +######## + + , 100 ); + + ## + AddIdentityMorphism( cat, + +######## +function ( cat_1, a_1 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, a_1, AsFunc, ID_FUNC ); +end +######## + + , 100 ); + + ## + AddImageEmbeddingWithGivenImageObject( cat, + +######## +function ( cat_1, alpha_1, I_1 ) + local hoisted_1_1; + hoisted_1_1 := SSortedList( List( [ 0 .. Length( Source( alpha_1 ) ) - 1 ], AsFunc( alpha_1 ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, I_1, Range( alpha_1 ), AsFunc, function ( i_2 ) + return hoisted_1_1[1 + i_2]; + end ); +end +######## + + , 100 ); + + ## + AddImageObject( cat, + +######## +function ( cat_1, arg2_1 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( Length( SSortedList( List( [ 0 .. Length( Source( arg2_1 ) ) - 1 ], AsFunc( arg2_1 ) ) ) ) ) ); +end +######## + + , 100 ); + + ## + AddInitialObject( cat, + +######## +function ( cat_1 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( 0 ) ); +end +######## + + , 100 ); + + ## + AddInjectionOfCofactorOfCoproductWithGivenCoproduct( cat, + +######## +function ( cat_1, objects_1, k_1, P_1 ) + local hoisted_1_1; + hoisted_1_1 := Sum( List( objects_1, Length ){[ 1 .. k_1 - 1 ]} ); + return CreateCapCategoryMorphismWithAttributes( cat_1, objects_1[k_1], P_1, AsFunc, function ( i_2 ) + return hoisted_1_1 + i_2; + end ); +end +######## + + , 100 ); + + ## + AddIsColiftable( cat, + +######## +function ( cat_1, arg2_1, arg3_1 ) + local hoisted_2_1, deduped_3_1; + deduped_3_1 := List( [ 0 .. Length( Source( arg2_1 ) ) - 1 ], AsFunc( arg2_1 ) ); + hoisted_2_1 := List( [ 0 .. Length( Source( arg3_1 ) ) - 1 ], AsFunc( arg3_1 ) ); + return ForAll( SSortedList( deduped_3_1 ), function ( i_2 ) + return Length( SSortedList( hoisted_2_1{Positions( deduped_3_1, i_2 )} ) ) = 1; + end ); +end +######## + + , 100 ); + + ## + AddIsEpimorphism( cat, + +######## +function ( cat_1, arg2_1 ) + return not false in SKELETAL_FIN_SETS_IsEpimorphism( List( [ 0 .. Length( Source( arg2_1 ) ) - 1 ], AsFunc( arg2_1 ) ), Length( Range( arg2_1 ) ) ); +end +######## + + , 100 ); + + ## + AddIsEqualForMorphisms( cat, + +######## +function ( cat_1, arg2_1, arg3_1 ) + local hoisted_1_1, hoisted_2_1; + hoisted_2_1 := AsFunc( arg3_1 ); + hoisted_1_1 := AsFunc( arg2_1 ); + return ForAll( [ 0 .. Length( Source( arg2_1 ) ) - 1 ], function ( x_2 ) + return hoisted_1_1( x_2 ) = hoisted_2_1( x_2 ); + end ); +end +######## + + , 100 ); + + ## + AddIsEqualForObjects( cat, + +######## +function ( cat_1, arg2_1, arg3_1 ) + return Length( arg2_1 ) = Length( arg3_1 ); +end +######## + + , 100 ); + + ## + AddIsHomSetInhabited( cat, + +######## +function ( cat_1, arg2_1, arg3_1 ) + return Length( arg2_1 ) = 0 or Length( arg3_1 ) <> 0; +end +######## + + , 100 ); + + ## + AddIsInitial( cat, + +######## +function ( cat_1, arg2_1 ) + return Length( arg2_1 ) = 0; +end +######## + + , 100 ); + + ## + AddIsInjective( cat, + +######## +function ( cat_1, arg2_1 ) + return Length( arg2_1 ) <> 0; +end +######## + + , 100 ); + + ## + AddIsLiftable( cat, + +######## +function ( cat_1, arg2_1, arg3_1 ) + local hoisted_1_1, deduped_2_1, deduped_3_1, deduped_4_1; + deduped_4_1 := [ 0 .. Length( Source( arg3_1 ) ) - 1 ]; + deduped_3_1 := [ 0 .. Length( Source( arg2_1 ) ) - 1 ]; + deduped_2_1 := List( deduped_3_1, AsFunc( arg2_1 ) ); + hoisted_1_1 := List( deduped_4_1, AsFunc( arg3_1 ) ); + return ForAll( IdFunc( function ( ) + if 100 * Length( deduped_3_1 ) < Length( deduped_4_1 ) then + return SSortedList( deduped_2_1 ); + else + return deduped_2_1; + fi; + return; + end )( ), function ( y_2 ) + return y_2 in hoisted_1_1; + end ); +end +######## + + , 100 ); + + ## + AddIsMonomorphism( cat, + +######## +function ( cat_1, arg2_1 ) + return SKELETAL_FIN_SETS_IsMonomorphism( List( [ 0 .. Length( Source( arg2_1 ) ) - 1 ], AsFunc( arg2_1 ) ), Length( Range( arg2_1 ) ) ); +end +######## + + , 100 ); + + ## + AddIsProjective( cat, + +######## +function ( cat_1, arg2_1 ) + return true; +end +######## + + , 100 ); + + ## + AddIsSplitEpimorphism( cat, + +######## +function ( cat_1, arg2_1 ) + return not false in SKELETAL_FIN_SETS_IsEpimorphism( List( [ 0 .. Length( Source( arg2_1 ) ) - 1 ], AsFunc( arg2_1 ) ), Length( Range( arg2_1 ) ) ); +end +######## + + , 100 ); + + ## + AddIsSplitMonomorphism( cat, + +######## +function ( cat_1, arg2_1 ) + local deduped_1_1, deduped_2_1; + deduped_2_1 := Length( Source( arg2_1 ) ); + deduped_1_1 := Length( Range( arg2_1 ) ); + return deduped_1_1 = 0 or deduped_2_1 <> 0 and SKELETAL_FIN_SETS_IsMonomorphism( List( [ 0 .. deduped_2_1 - 1 ], AsFunc( arg2_1 ) ), deduped_1_1 ); +end +######## + + , 100 ); + + ## + AddIsTerminal( cat, + +######## +function ( cat_1, arg2_1 ) + return Length( arg2_1 ) = 1; +end +######## + + , 100 ); + + ## + AddIsWellDefinedForMorphisms( cat, + +######## +function ( cat_1, arg2_1 ) + local hoisted_1_1, hoisted_2_1; + hoisted_2_1 := Length( Range( arg2_1 ) ); + hoisted_1_1 := AsFunc( arg2_1 ); + if not ForAll( [ 0 .. Length( Source( arg2_1 ) ) - 1 ], function ( x_2 ) + local deduped_1_2; + deduped_1_2 := hoisted_1_1( x_2 ); + return (IsBigInt( deduped_1_2 ) and deduped_1_2 >= 0 and deduped_1_2 < hoisted_2_1); + end ) then + return false; + else + return true; + fi; + return; +end +######## + + , 100 ); + + ## + AddIsWellDefinedForObjects( cat, + +######## +function ( cat_1, arg2_1 ) + return Length( arg2_1 ) >= 0; +end +######## + + , 100 ); + + ## + AddLift( cat, + +######## +function ( cat_1, alpha_1, beta_1 ) + local hoisted_1_1, hoisted_2_1, deduped_3_1; + deduped_3_1 := Source( beta_1 ); + hoisted_2_1 := List( [ 0 .. Length( deduped_3_1 ) - 1 ], AsFunc( beta_1 ) ); + hoisted_1_1 := AsFunc( alpha_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Source( alpha_1 ), deduped_3_1, AsFunc, function ( x_2 ) + return -1 + BigInt( SafePosition( hoisted_2_1, hoisted_1_1( x_2 ) ) ); + end ); +end +######## + + , 100 ); + + ## + AddMonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject( cat, + +######## +function ( cat_1, A_1, I_1 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, A_1, I_1, AsFunc, ID_FUNC ); +end +######## + + , 100 ); + + ## + AddMorphismConstructor( cat, + +######## +function ( cat_1, arg2_1, arg3_1, arg4_1 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, arg2_1, arg4_1, AsFunc, arg3_1 ); +end +######## + + , 100 ); + + ## + AddMorphismDatum( cat, + +######## +function ( cat_1, arg2_1 ) + return AsFunc( arg2_1 ); +end +######## + + , 100 ); + + ## + AddMorphismsOfExternalHom( cat, + +######## +function ( cat_1, arg2_1, arg3_1 ) + local deduped_2_1; + deduped_2_1 := Length( arg3_1 ); + return List( [ 0 .. deduped_2_1 ^ Length( arg2_1 ) - 1 ], function ( logic_new_func_x_2 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, arg2_1, arg3_1, AsFunc, function ( i_3 ) + return REM_INT( QUO_INT( logic_new_func_x_2, deduped_2_1 ^ i_3 ), deduped_2_1 ); + end ); + end ); +end +######## + + , 401 ); + + ## + AddObjectConstructor( cat, + +######## +function ( cat_1, arg2_1 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, arg2_1 ); +end +######## + + , 100 ); + + ## + AddObjectDatum( cat, + +######## +function ( cat_1, arg2_1 ) + return Length( arg2_1 ); +end +######## + + , 100 ); + + ## + AddPreCompose( cat, + +######## +function ( cat_1, alpha_1, beta_1 ) + local hoisted_1_1, hoisted_2_1; + hoisted_2_1 := AsFunc( beta_1 ); + hoisted_1_1 := AsFunc( alpha_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Source( alpha_1 ), Range( beta_1 ), AsFunc, function ( i_2 ) + return hoisted_2_1( hoisted_1_1( i_2 ) ); + end ); +end +######## + + , 100 ); + + ## + AddProjectionInFactorOfDirectProductWithGivenDirectProduct( cat, + +######## +function ( cat_1, objects_1, k_1, P_1 ) + local hoisted_1_1, hoisted_2_1, deduped_3_1; + deduped_3_1 := List( objects_1, Length ); + hoisted_2_1 := deduped_3_1[k_1]; + hoisted_1_1 := Product( deduped_3_1{[ 1 .. k_1 - 1 ]} ); + return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, objects_1[k_1], AsFunc, function ( i_2 ) + return REM_INT( QUO_INT( i_2, hoisted_1_1 ), hoisted_2_1 ); + end ); +end +######## + + , 100 ); + + ## + AddProjectionOntoCoequalizerWithGivenCoequalizer( cat, + +######## +function ( cat_1, Y_1, morphisms_1, P_1 ) + local hoisted_1_1; + hoisted_1_1 := SKELETAL_FIN_SETS_ExplicitCoequalizer( Y_1, morphisms_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, Y_1, P_1, AsFunc, function ( i_2 ) + return -1 + BigInt( SafeUniquePositionProperty( hoisted_1_1, function ( c_3 ) + return (i_2 in c_3); + end ) ); + end ); +end +######## + + , 100 ); + + ## + AddPushoutComplement( cat, + +######## +function ( cat_1, l_1, m_1 ) + local deduped_5_1, deduped_6_1, hoisted_8_1, hoisted_10_1, hoisted_15_1, hoisted_18_1, hoisted_19_1, deduped_22_1, deduped_23_1, deduped_24_1, deduped_25_1, deduped_26_1, deduped_27_1, deduped_28_1, deduped_29_1, deduped_30_1, deduped_31_1, deduped_32_1, deduped_33_1, deduped_34_1, deduped_35_1, deduped_36_1, deduped_37_1, deduped_38_1; + deduped_38_1 := BigInt( 3 ); + deduped_37_1 := BigInt( 2 ); + deduped_36_1 := BigInt( 1 ); + deduped_35_1 := BigInt( 0 ); + deduped_34_1 := Range( m_1 ); + deduped_33_1 := Length( Source( l_1 ) ); + deduped_32_1 := Length( Source( m_1 ) ); + deduped_31_1 := Length( deduped_34_1 ); + deduped_30_1 := Filtered( [ deduped_35_1, deduped_36_1, deduped_37_1, deduped_38_1 ], function ( x_2 ) + return IdFunc( function ( ) + if (x_2 = deduped_38_1) then + return deduped_36_1; + else + return deduped_35_1; + fi; + return; + end )( ) = REM_INT( x_2, deduped_37_1 ); + end ); + hoisted_10_1 := AsFunc( l_1 ); + deduped_29_1 := Filtered( [ 0 .. deduped_32_1 * deduped_33_1 - 1 ], function ( i_2 ) + return REM_INT( QUO_INT( i_2, deduped_36_1 ), deduped_32_1 ) = hoisted_10_1( REM_INT( QUO_INT( i_2, deduped_32_1 ), deduped_33_1 ) ); + end ); + deduped_28_1 := Filtered( [ 0 .. deduped_32_1 * deduped_32_1 - 1 ], function ( x_2 ) + return REM_INT( QUO_INT( x_2, deduped_36_1 ), deduped_32_1 ) = REM_INT( QUO_INT( x_2, deduped_32_1 ), deduped_32_1 ); + end ); + deduped_27_1 := Length( deduped_29_1 ); + deduped_26_1 := Filtered( [ 0 .. deduped_27_1 * deduped_33_1 - 1 ], function ( x_2 ) + return REM_INT( QUO_INT( deduped_29_1[1 + REM_INT( QUO_INT( x_2, deduped_36_1 ), deduped_27_1 )], deduped_32_1 ), deduped_33_1 ) = REM_INT( QUO_INT( x_2, deduped_27_1 ), deduped_33_1 ); + end ); + deduped_6_1 := deduped_31_1 * deduped_35_1; + deduped_5_1 := AsFunc( m_1 ); + deduped_25_1 := SSortedList( List( [ 0 .. Length( deduped_28_1 ) - 1 ], function ( i_2 ) + return deduped_36_1 * deduped_5_1( REM_INT( QUO_INT( deduped_28_1[(1 + i_2)], deduped_36_1 ), deduped_32_1 ) ) + deduped_6_1; + end ) ); + deduped_23_1 := SSortedList( List( [ 0 .. Length( deduped_26_1 ) - 1 ], function ( i_2 ) + return deduped_36_1 * deduped_5_1( REM_INT( QUO_INT( deduped_29_1[(1 + REM_INT( QUO_INT( deduped_26_1[(1 + i_2)], deduped_36_1 ), deduped_27_1 ))], deduped_36_1 ), deduped_32_1 ) ) + deduped_6_1; + end ) ); + hoisted_19_1 := [ deduped_35_1 ]; + hoisted_18_1 := deduped_30_1{[ 1 .. Length( deduped_30_1 ) ]}; + hoisted_15_1 := List( [ 0 .. BigInt( Length( deduped_23_1 ) ) - 1 ], function ( i_2 ) + return deduped_23_1[1 + i_2]; + end ); + hoisted_8_1 := List( [ 0 .. BigInt( Length( deduped_25_1 ) ) - 1 ], function ( i_2 ) + return deduped_25_1[1 + i_2]; + end ); + deduped_24_1 := Filtered( [ 0 .. deduped_31_1 - 1 ], function ( i_2 ) + local deduped_1_2; + deduped_1_2 := REM_INT( QUO_INT( i_2, deduped_36_1 ), deduped_31_1 ); + return IdFunc( function ( ) + if (deduped_36_1 * IdFunc( function ( ) + if (deduped_1_2 in hoisted_8_1) then + return deduped_36_1; + else + return deduped_35_1; + fi; + return; + end )( ) + deduped_37_1 * IdFunc( function ( ) + if (deduped_1_2 in hoisted_15_1) then + return deduped_36_1; + else + return deduped_35_1; + fi; + return; + end )( ) in hoisted_18_1) then + return deduped_36_1; + else + return deduped_35_1; + fi; + return; + end )( ) = IdFunc( function ( ) + if (REM_INT( QUO_INT( i_2, deduped_31_1 ), deduped_36_1 ) in hoisted_19_1) then + return deduped_36_1; + else + return deduped_35_1; + fi; + return; + end )( ); + end ); + deduped_22_1 := SSortedList( List( [ 0 .. Length( deduped_24_1 ) - 1 ], function ( i_2 ) + return REM_INT( QUO_INT( deduped_24_1[1 + i_2], deduped_36_1 ), deduped_31_1 ); + end ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( Length( deduped_22_1 ) ) ), deduped_34_1, AsFunc, function ( i_2 ) + return deduped_22_1[1 + i_2]; + end ); +end +######## + + , 19767 : IsPrecompiledDerivation := true ); + + ## + AddSomeInjectiveObject( cat, + +######## +function ( cat_1, arg2_1 ) + if Length( arg2_1 ) = 0 then + return CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( 1 ) ); + else + return arg2_1; + fi; + return; +end +######## + + , 100 ); + + ## + AddSubobjectClassifier( cat, + +######## +function ( cat_1 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( 2 ) ); +end +######## + + , 100 ); + + ## + AddTerminalObject( cat, + +######## +function ( cat_1 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( 1 ) ); +end +######## + + , 100 ); + + ## + AddUniversalMorphismFromCoequalizerWithGivenCoequalizer( cat, + +######## +function ( cat_1, Y_1, morphisms_1, T_1, tau_1, P_1 ) + local hoisted_1_1, hoisted_2_1; + hoisted_2_1 := AsFunc( tau_1 ); + hoisted_1_1 := SKELETAL_FIN_SETS_ExplicitCoequalizer( Y_1, morphisms_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, Range( tau_1 ), AsFunc, function ( i_2 ) + return hoisted_2_1( hoisted_1_1[1 + i_2][1] ); + end ); +end +######## + + , 100 ); + + ## + AddUniversalMorphismFromCoproductWithGivenCoproduct( cat, + +######## +function ( cat_1, objects_1, T_1, tau_1, P_1 ) + local hoisted_1_1, deduped_2_1, hoisted_3_1, hoisted_4_1, deduped_5_1; + deduped_5_1 := Length( tau_1 ); + hoisted_4_1 := List( tau_1, AsFunc ); + hoisted_3_1 := [ 1 .. deduped_5_1 ]; + hoisted_1_1 := List( tau_1, function ( map_2 ) + return Length( Source( map_2 ) ); + end ); + deduped_2_1 := List( [ 0 .. deduped_5_1 ], function ( k_2 ) + return Sum( hoisted_1_1{[ 1 .. k_2 ]} ); + end ); + return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, T_1, AsFunc, function ( i_2 ) + local deduped_1_2; + deduped_1_2 := SafePositionProperty( hoisted_3_1, function ( k_3 ) + return i_2 < deduped_2_1[k_3 + 1]; + end ); + return hoisted_4_1[deduped_1_2]( i_2 - deduped_2_1[deduped_1_2] ); + end ); +end +######## + + , 100 ); + + ## + AddUniversalMorphismFromInitialObjectWithGivenInitialObject( cat, + +######## +function ( cat_1, T_1, P_1 ) + return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, T_1, AsFunc, ID_FUNC ); +end +######## + + , 100 ); + + ## + AddUniversalMorphismIntoDirectProductWithGivenDirectProduct( cat, + +######## +function ( cat_1, objects_1, T_1, tau_1, P_1 ) + local hoisted_1_1, hoisted_2_1, hoisted_3_1, deduped_5_1; + deduped_5_1 := [ 0 .. Length( objects_1 ) - 1 ]; + hoisted_3_1 := List( tau_1, AsFunc ); + hoisted_1_1 := List( objects_1, Length ); + hoisted_2_1 := List( deduped_5_1, function ( j_2 ) + return Product( hoisted_1_1{[ 1 .. j_2 ]} ); + end ); + return CreateCapCategoryMorphismWithAttributes( cat_1, T_1, P_1, AsFunc, function ( i_2 ) + return Sum( deduped_5_1, function ( j_3 ) + local deduped_1_3; + deduped_1_3 := 1 + j_3; + return hoisted_2_1[deduped_1_3] * hoisted_3_1[deduped_1_3]( i_2 ); + end ); + end ); +end +######## + + , 100 ); + + ## + AddUniversalMorphismIntoEqualizerWithGivenEqualizer( cat, + +######## +function ( cat_1, Y_1, morphisms_1, T_1, tau_1, P_1 ) + local deduped_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1; + hoisted_2_1 := [ 1 .. Length( morphisms_1 ) - 1 ]; + deduped_1_1 := List( morphisms_1, AsFunc ); + hoisted_4_1 := Filtered( [ 0 .. Length( Y_1 ) - 1 ], function ( x_2 ) + return ForAll( hoisted_2_1, function ( j_3 ) + return deduped_1_1[j_3]( x_2 ) = deduped_1_1[j_3 + 1]( x_2 ); + end ); + end ); + hoisted_3_1 := AsFunc( tau_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, T_1, P_1, AsFunc, function ( x_2 ) + return -1 + BigInt( SafePosition( hoisted_4_1, hoisted_3_1( x_2 ) ) ); + end ); +end +######## + + , 100 ); + + ## + AddUniversalMorphismIntoTerminalObjectWithGivenTerminalObject( cat, + +######## +function ( cat_1, T_1, P_1 ) + local hoisted_1_1; + hoisted_1_1 := BigInt( 0 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, T_1, P_1, AsFunc, function ( i_2 ) + return hoisted_1_1; + end ); +end +######## + + , 100 ); + + if IsBound( cat!.precompiled_functions_added ) then + + # COVERAGE_IGNORE_NEXT_LINE + Error( "precompiled functions have already been added before" ); + + fi; + + cat!.precompiled_functions_added := true; + +end ); + +BindGlobal( "CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled", function ( ) + local category_constructor, cat; + + category_constructor := + + + function ( ) + return CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctions( ); +end; + + + + cat := category_constructor( : FinalizeCategory := false, no_precompiled_code := true ); + + ADD_FUNCTIONS_FOR_CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled( cat ); + + Finalize( cat ); + + return cat; + +end ); diff --git a/gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled.gi b/gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled.gi index 9fb24ec..57679d6 100644 --- a/gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled.gi +++ b/gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled.gi @@ -45,12 +45,11 @@ end ######## function ( cat_1, a_1, b_1, s_1 ) - local deduped_3_1, deduped_4_1, deduped_5_1; - deduped_5_1 := Length( a_1 ); - deduped_4_1 := Length( b_1 ); - deduped_3_1 := deduped_4_1 ^ deduped_5_1; - return CreateCapCategoryMorphismWithAttributes( cat_1, s_1, b_1, AsList, List( [ 0 .. deduped_3_1 * deduped_5_1 - 1 ], function ( i_2 ) - return REM_INT( QUO_INT( i_2, deduped_4_1 ^ QUO_INT( i_2, deduped_3_1 ) ), deduped_4_1 ); + local hoisted_1_1, deduped_3_1; + deduped_3_1 := Length( b_1 ); + hoisted_1_1 := deduped_3_1 ^ Length( a_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, s_1, b_1, AsList, List( [ 0 .. Length( s_1 ) - 1 ], function ( i_2 ) + return REM_INT( QUO_INT( i_2, deduped_3_1 ^ QUO_INT( i_2, hoisted_1_1 ) ), deduped_3_1 ); end ) ); end ######## @@ -95,7 +94,7 @@ end ######## function ( cat_1, a_1, r_1 ) - return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, a_1, AsList, [ 0 .. Length( a_1 ) - 1 ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, r_1, AsList, [ 0 .. Length( a_1 ) - 1 ] ); end ######## @@ -106,7 +105,7 @@ end ######## function ( cat_1, a_1, s_1 ) - return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, a_1, AsList, [ 0 .. Length( a_1 ) - 1 ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, s_1, a_1, AsList, [ 0 .. Length( a_1 ) - 1 ] ); end ######## @@ -117,7 +116,7 @@ end ######## function ( cat_1, a_1, r_1 ) - return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, a_1, AsList, [ 0 .. Length( a_1 ) - 1 ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, r_1, AsList, [ 0 .. Length( a_1 ) - 1 ] ); end ######## @@ -128,7 +127,7 @@ end ######## function ( cat_1, a_1, s_1 ) - return CreateCapCategoryMorphismWithAttributes( cat_1, a_1, a_1, AsList, [ 0 .. Length( a_1 ) - 1 ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, s_1, a_1, AsList, [ 0 .. Length( a_1 ) - 1 ] ); end ######## @@ -238,12 +237,12 @@ function ( cat_1, Y_1, morphisms_1, P_1 ) hoisted_2_1 := [ 1 .. Length( morphisms_1 ) - 1 ]; deduped_1_1 := List( morphisms_1, AsList ); return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, Y_1, AsList, Filtered( [ 0 .. Length( Y_1 ) - 1 ], function ( x_2 ) - local deduped_1_2; - deduped_1_2 := 1 + x_2; - return ForAll( hoisted_2_1, function ( j_3 ) - return deduped_1_1[j_3][deduped_1_2] = deduped_1_1[j_3 + 1][deduped_1_2]; - end ); - end ) ); + local deduped_1_2; + deduped_1_2 := 1 + x_2; + return ForAll( hoisted_2_1, function ( j_3 ) + return deduped_1_1[j_3][deduped_1_2] = deduped_1_1[j_3 + 1][deduped_1_2]; + end ); + end ){[ 1 .. Length( P_1 ) ]} ); end ######## @@ -268,9 +267,9 @@ function ( cat_1, arg2_1, arg3_1 ) local deduped_1_1, hoisted_2_1; hoisted_2_1 := [ 1 .. Length( arg3_1 ) - 1 ]; deduped_1_1 := List( arg3_1, AsList ); - return CreateCapCategoryObjectWithAttributes( cat_1, Length, Length( Filtered( [ 0 .. Length( arg2_1 ) - 1 ], function ( x_2 ) + return CreateCapCategoryObjectWithAttributes( cat_1, Length, Length( Filtered( [ 0 .. Length( arg2_1 ) - 1 ], function ( i_2 ) local deduped_1_2; - deduped_1_2 := 1 + x_2; + deduped_1_2 := 1 + i_2; return ForAll( hoisted_2_1, function ( j_3 ) return deduped_1_1[j_3][deduped_1_2] = deduped_1_1[j_3 + 1][deduped_1_2]; end ); @@ -300,27 +299,21 @@ end ######## function ( cat_1, s_1, alpha_1, beta_1, r_1 ) - local hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, hoisted_6_1, deduped_7_1, deduped_8_1; - deduped_8_1 := Length( Range( alpha_1 ) ); - deduped_7_1 := Length( Source( beta_1 ) ); - hoisted_6_1 := [ 0 .. Length( Source( alpha_1 ) ) - 1 ]; - hoisted_5_1 := Length( Range( beta_1 ) ); - hoisted_4_1 := AsList( beta_1 ); - hoisted_3_1 := AsList( alpha_1 ); - hoisted_2_1 := [ 0 .. deduped_8_1 - 1 ]; - return CreateCapCategoryMorphismWithAttributes( cat_1, s_1, r_1, AsList, List( [ 0 .. deduped_7_1 ^ deduped_8_1 - 1 ], function ( i_2 ) - local hoisted_1_2; - hoisted_1_2 := List( hoisted_2_1, function ( i_3 ) - return REM_INT( QUO_INT( i_2, deduped_7_1 ^ i_3 ), deduped_7_1 ); - end ); - return Sum( List( hoisted_6_1, function ( k_3 ) - return hoisted_4_1[(1 + hoisted_1_2[(1 + hoisted_3_1[(1 + CAP_JIT_INCOMPLETE_LOGIC( k_3 ))])])] * hoisted_5_1 ^ k_3; + local hoisted_1_1, deduped_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1; + hoisted_5_1 := [ 0 .. Length( Source( alpha_1 ) ) - 1 ]; + hoisted_4_1 := Length( Range( beta_1 ) ); + hoisted_3_1 := AsList( beta_1 ); + deduped_2_1 := Length( Source( beta_1 ) ); + hoisted_1_1 := AsList( alpha_1 ); + return CreateCapCategoryMorphismWithAttributes( cat_1, s_1, r_1, AsList, List( [ 0 .. Length( s_1 ) - 1 ], function ( i_2 ) + return Sum( List( hoisted_5_1, function ( k_3 ) + return hoisted_3_1[(1 + REM_INT( QUO_INT( i_2, deduped_2_1 ^ hoisted_1_1[(1 + k_3)] ), deduped_2_1 ))] * hoisted_4_1 ^ k_3; end ) ); end ) ); end ######## - , 1003 ); + , 100 ); ## AddExponentialOnObjects( cat, @@ -349,7 +342,7 @@ end ######## function ( cat_1, alpha_1, I_1 ) - return CreateCapCategoryMorphismWithAttributes( cat_1, I_1, Range( alpha_1 ), AsList, SSortedList( AsList( alpha_1 ) ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, I_1, Range( alpha_1 ), AsList, SSortedList( AsList( alpha_1 ) ){[ 1 .. Length( I_1 ) ]} ); end ######## @@ -478,18 +471,18 @@ end ######## function ( cat_1, arg2_1, arg3_1 ) - local deduped_2_1, deduped_3_1; - deduped_3_1 := AsList( arg3_1 ); + local hoisted_1_1, deduped_2_1; deduped_2_1 := AsList( arg2_1 ); + hoisted_1_1 := AsList( arg3_1 ); return ForAll( IdFunc( function ( ) - if 100 * Length( deduped_2_1 ) < Length( deduped_3_1 ) then + if 100 * Length( Source( arg2_1 ) ) < Length( Source( arg3_1 ) ) then return SSortedList( deduped_2_1 ); else return deduped_2_1; fi; return; end )( ), function ( y_2 ) - return y_2 in deduped_3_1; + return y_2 in hoisted_1_1; end ); end ######## @@ -558,17 +551,15 @@ end ######## function ( cat_1, arg2_1 ) - local hoisted_1_1, deduped_2_1; - deduped_2_1 := AsList( arg2_1 ); - hoisted_1_1 := Length( Range( arg2_1 ) ); - if not ForAll( deduped_2_1, function ( a_2 ) - return (IsBigInt( a_2 ) and a_2 >= 0); - end ) then - return false; - elif Length( Source( arg2_1 ) ) <> Length( deduped_2_1 ) then - return false; - elif not ForAll( deduped_2_1, function ( a_2 ) - return a_2 < hoisted_1_1; + local hoisted_1_1, hoisted_3_1, deduped_4_1; + deduped_4_1 := AsList( arg2_1 ); + hoisted_3_1 := Length( Range( arg2_1 ) ); + hoisted_1_1 := List( deduped_4_1, IsBigInt ); + if not ForAll( [ 0 .. Length( Source( arg2_1 ) ) - 1 ], function ( x_2 ) + local deduped_1_2, deduped_2_2; + deduped_2_2 := 1 + x_2; + deduped_1_2 := deduped_4_1[deduped_2_2]; + return (hoisted_1_1[deduped_2_2] and deduped_1_2 >= 0 and deduped_1_2 < hoisted_3_1); end ) then return false; else @@ -738,77 +729,137 @@ end ######## function ( cat_1, l_1, m_1 ) - local deduped_3_1, deduped_5_1, hoisted_6_1, deduped_8_1, hoisted_10_1, hoisted_13_1, hoisted_15_1, hoisted_16_1, hoisted_17_1, hoisted_18_1, deduped_20_1, deduped_21_1, deduped_22_1, deduped_23_1, deduped_24_1, deduped_25_1, deduped_26_1, deduped_27_1, deduped_28_1, deduped_29_1, deduped_30_1, deduped_31_1, deduped_32_1, deduped_33_1, deduped_34_1, deduped_35_1, deduped_36_1; - deduped_36_1 := BigInt( 1 ); - deduped_35_1 := BigInt( 0 ); - deduped_34_1 := Range( m_1 ); - deduped_33_1 := Length( Source( l_1 ) ); - deduped_32_1 := Length( Source( m_1 ) ); - deduped_31_1 := Length( deduped_34_1 ); - deduped_30_1 := [ 0 .. deduped_31_1 - 1 ]; - deduped_29_1 := [ 0 .. deduped_32_1 * deduped_33_1 - 1 ]; - deduped_28_1 := [ 0 .. deduped_32_1 * deduped_32_1 - 1 ]; - deduped_3_1 := List( deduped_28_1, function ( i_2 ) - return REM_INT( i_2, deduped_32_1 ); - end ); - deduped_27_1 := Filtered( deduped_28_1, function ( x_2 ) - return deduped_3_1[1 + x_2] = REM_INT( QUO_INT( CAP_JIT_INCOMPLETE_LOGIC( x_2 ), deduped_32_1 ), deduped_32_1 ); + local deduped_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1, hoisted_8_1, deduped_10_1, hoisted_12_1, deduped_13_1, hoisted_15_1, hoisted_16_1, hoisted_17_1, hoisted_18_1, hoisted_19_1, hoisted_20_1, hoisted_22_1, hoisted_23_1, deduped_24_1, hoisted_25_1, deduped_26_1, deduped_27_1, deduped_28_1, deduped_29_1, deduped_30_1, deduped_31_1, deduped_32_1, deduped_33_1, deduped_34_1, deduped_35_1, deduped_36_1, deduped_37_1, deduped_38_1, deduped_39_1, deduped_40_1, deduped_41_1, deduped_42_1, deduped_43_1, deduped_44_1, deduped_45_1, deduped_46_1, deduped_47_1, deduped_48_1, deduped_49_1, deduped_50_1, deduped_51_1, deduped_52_1, deduped_53_1, deduped_54_1, deduped_55_1, deduped_56_1, deduped_57_1; + deduped_57_1 := BigInt( 3 ); + deduped_56_1 := BigInt( 2 ); + deduped_55_1 := BigInt( 1 ); + deduped_54_1 := BigInt( 0 ); + deduped_53_1 := Range( m_1 ); + deduped_52_1 := Length( Source( l_1 ) ); + deduped_51_1 := Length( Source( m_1 ) ); + deduped_50_1 := Length( deduped_53_1 ); + deduped_49_1 := [ deduped_54_1, deduped_56_1, deduped_57_1 ]{[ 1, 2, 3 ]}; + deduped_48_1 := [ 0 .. deduped_50_1 - 1 ]; + deduped_47_1 := [ 0 .. deduped_51_1 * deduped_52_1 - 1 ]; + deduped_46_1 := [ 0 .. deduped_51_1 * deduped_51_1 - 1 ]; + deduped_3_1 := List( deduped_46_1, function ( i_2 ) + return REM_INT( i_2, deduped_51_1 ); end ); - hoisted_10_1 := AsList( l_1 ); - deduped_8_1 := List( deduped_29_1, function ( i_2 ) - return REM_INT( i_2, deduped_32_1 ); + deduped_45_1 := Filtered( deduped_46_1, function ( x_2 ) + return deduped_3_1[1 + x_2] = REM_INT( QUO_INT( CAP_JIT_INCOMPLETE_LOGIC( x_2 ), deduped_51_1 ), deduped_51_1 ); end ); - deduped_26_1 := Filtered( deduped_29_1, function ( x_2 ) - return deduped_8_1[1 + x_2] = hoisted_10_1[1 + REM_INT( QUO_INT( CAP_JIT_INCOMPLETE_LOGIC( x_2 ), deduped_32_1 ), deduped_33_1 )]; + deduped_44_1 := Length( deduped_45_1 ); + deduped_43_1 := [ 1 .. deduped_44_1 ]; + hoisted_12_1 := AsList( l_1 ); + deduped_10_1 := List( deduped_47_1, function ( i_2 ) + return REM_INT( i_2, deduped_51_1 ); end ); - deduped_25_1 := Length( deduped_26_1 ); - deduped_24_1 := [ 0 .. deduped_25_1 - 1 ]; - hoisted_13_1 := List( deduped_24_1, function ( i_2 ) - return REM_INT( QUO_INT( CAP_JIT_INCOMPLETE_LOGIC( deduped_26_1[1 + i_2] ), deduped_32_1 ), deduped_33_1 ); + deduped_42_1 := Filtered( deduped_47_1, function ( x_2 ) + return deduped_10_1[1 + x_2] = hoisted_12_1[1 + REM_INT( QUO_INT( CAP_JIT_INCOMPLETE_LOGIC( x_2 ), deduped_51_1 ), deduped_52_1 )]; end ); - deduped_23_1 := Filtered( [ 0 .. deduped_25_1 * deduped_33_1 - 1 ], function ( x_2 ) + deduped_41_1 := [ 0 .. deduped_44_1 - 1 ]; + deduped_40_1 := Length( deduped_42_1 ); + deduped_39_1 := [ 1 .. deduped_40_1 ]; + deduped_38_1 := [ 0 .. deduped_40_1 - 1 ]; + deduped_7_1 := deduped_50_1 * deduped_54_1; + deduped_6_1 := AsList( m_1 ); + hoisted_4_1 := deduped_45_1{deduped_43_1}; + hoisted_5_1 := List( deduped_41_1, function ( i_2 ) + return deduped_3_1[1 + hoisted_4_1[(1 + i_2)]]; + end ){deduped_43_1}; + deduped_37_1 := SSortedList( List( deduped_41_1, function ( i_2 ) + return deduped_6_1[1 + hoisted_5_1[(1 + CAP_JIT_INCOMPLETE_LOGIC( i_2 ))]] + deduped_7_1; + end ) ); + deduped_13_1 := deduped_42_1{deduped_39_1}; + hoisted_15_1 := (List( deduped_38_1, function ( i_2 ) + return REM_INT( QUO_INT( CAP_JIT_INCOMPLETE_LOGIC( deduped_13_1[1 + i_2] ), deduped_51_1 ), deduped_52_1 ); + end ){deduped_39_1}){deduped_39_1}; + deduped_36_1 := Filtered( [ 0 .. deduped_40_1 * deduped_52_1 - 1 ], function ( x_2 ) local deduped_1_2; deduped_1_2 := CAP_JIT_INCOMPLETE_LOGIC( x_2 ); - return hoisted_13_1[1 + REM_INT( deduped_1_2, deduped_25_1 )] = REM_INT( QUO_INT( deduped_1_2, deduped_25_1 ), deduped_33_1 ); - end ); - hoisted_18_1 := [ deduped_36_1, deduped_35_1, deduped_36_1, deduped_36_1 ]; - hoisted_17_1 := BigInt( 2 ); - deduped_5_1 := AsList( m_1 ); - hoisted_15_1 := List( deduped_24_1, function ( i_2 ) - return deduped_5_1[1 + deduped_8_1[(1 + deduped_26_1[(1 + i_2)])]]; + return hoisted_15_1[1 + REM_INT( deduped_1_2, deduped_40_1 )] = REM_INT( QUO_INT( deduped_1_2, deduped_40_1 ), deduped_52_1 ); end ); - hoisted_16_1 := List( [ 0 .. Length( deduped_23_1 ) - 1 ], function ( i_2 ) - return hoisted_15_1[1 + REM_INT( CAP_JIT_INCOMPLETE_LOGIC( deduped_23_1[(1 + i_2)] ), deduped_25_1 )]; + deduped_34_1 := Length( deduped_36_1 ); + deduped_33_1 := [ 1 .. deduped_34_1 ]; + deduped_30_1 := [ 0 .. deduped_34_1 - 1 ]; + hoisted_16_1 := List( deduped_38_1, function ( i_2 ) + return deduped_10_1[1 + deduped_13_1[(1 + i_2)]]; + end ){deduped_39_1}; + hoisted_19_1 := List( deduped_38_1, function ( i_2 ) + return deduped_6_1[1 + hoisted_16_1[(1 + i_2)]]; end ); - hoisted_6_1 := List( [ 0 .. Length( deduped_27_1 ) - 1 ], function ( i_2 ) - return deduped_5_1[1 + deduped_3_1[(1 + deduped_27_1[(1 + i_2)])]]; - end ); - deduped_22_1 := Filtered( deduped_30_1, function ( x_2 ) + hoisted_17_1 := deduped_36_1{deduped_33_1}; + hoisted_18_1 := List( deduped_30_1, function ( i_2 ) + return REM_INT( CAP_JIT_INCOMPLETE_LOGIC( hoisted_17_1[1 + i_2] ), deduped_40_1 ); + end ){deduped_33_1}; + deduped_28_1 := SSortedList( List( deduped_30_1, function ( i_2 ) + return hoisted_19_1[1 + hoisted_18_1[(1 + CAP_JIT_INCOMPLETE_LOGIC( i_2 ))]] + deduped_7_1; + end ) ); + hoisted_22_1 := [ IdFunc( function ( ) + if deduped_54_1 in deduped_49_1 then + return deduped_55_1; + else + return deduped_54_1; + fi; + return; + end )( ), IdFunc( function ( ) + if deduped_55_1 in deduped_49_1 then + return deduped_55_1; + else + return deduped_54_1; + fi; + return; + end )( ), IdFunc( function ( ) + if deduped_56_1 in deduped_49_1 then + return deduped_55_1; + else + return deduped_54_1; + fi; + return; + end )( ), IdFunc( function ( ) + if deduped_57_1 in deduped_49_1 then + return deduped_55_1; + else + return deduped_54_1; + fi; + return; + end )( ) ]; + hoisted_20_1 := deduped_28_1{[ 1 .. BigInt( Length( deduped_28_1 ) ) ]}; + hoisted_8_1 := deduped_37_1{[ 1 .. BigInt( Length( deduped_37_1 ) ) ]}; + deduped_35_1 := Filtered( deduped_48_1, function ( i_2 ) local deduped_1_2; - deduped_1_2 := CAP_JIT_INCOMPLETE_LOGIC( REM_INT( CAP_JIT_INCOMPLETE_LOGIC( x_2 ), deduped_31_1 ) ); - return hoisted_18_1[1 + (IdFunc( function ( ) - if (deduped_1_2 in hoisted_6_1) then - return deduped_36_1; + deduped_1_2 := CAP_JIT_INCOMPLETE_LOGIC( REM_INT( CAP_JIT_INCOMPLETE_LOGIC( i_2 ), deduped_50_1 ) ); + return hoisted_22_1[1 + (IdFunc( function ( ) + if (deduped_1_2 in hoisted_8_1) then + return deduped_55_1; else - return deduped_35_1; + return deduped_54_1; fi; return; - end )( ) + IdFunc( function ( ) - if (deduped_1_2 in hoisted_16_1) then - return deduped_36_1; + end )( ) + deduped_56_1 * IdFunc( function ( ) + if (deduped_1_2 in hoisted_20_1) then + return deduped_55_1; else - return deduped_35_1; + return deduped_54_1; fi; return; - end )( ) * hoisted_17_1)] = deduped_36_1; + end )( ))] = deduped_55_1; end ); - deduped_20_1 := List( deduped_30_1, function ( i_2 ) - return REM_INT( i_2, deduped_31_1 ); + deduped_32_1 := Length( deduped_35_1 ); + deduped_31_1 := [ 1 .. deduped_32_1 ]; + deduped_29_1 := [ 0 .. deduped_32_1 - 1 ]; + deduped_24_1 := List( deduped_48_1, function ( i_2 ) + return REM_INT( i_2, deduped_50_1 ); end ); - deduped_21_1 := SSortedList( List( [ 0 .. Length( deduped_22_1 ) - 1 ], function ( i_2 ) - return deduped_20_1[1 + deduped_20_1[(1 + deduped_22_1[(1 + i_2)])]]; + hoisted_23_1 := deduped_35_1{deduped_31_1}; + hoisted_25_1 := List( deduped_29_1, function ( i_2 ) + return deduped_24_1[1 + hoisted_23_1[(1 + i_2)]]; + end ){deduped_31_1}; + deduped_27_1 := SSortedList( List( deduped_29_1, function ( i_2 ) + return deduped_24_1[1 + hoisted_25_1[(1 + i_2)]]; end ) ); - return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( Length( deduped_21_1 ) ) ), deduped_34_1, AsList, deduped_21_1 ); + deduped_26_1 := BigInt( Length( deduped_27_1 ) ); + return CreateCapCategoryMorphismWithAttributes( cat_1, CreateCapCategoryObjectWithAttributes( cat_1, Length, deduped_26_1 ), deduped_53_1, AsList, deduped_27_1{[ 1 .. deduped_26_1 ]} ); end ######## @@ -819,12 +870,16 @@ end ######## function ( cat_1, arg2_1 ) - if Length( arg2_1 ) = 0 then - return CreateCapCategoryObjectWithAttributes( cat_1, Length, BigInt( 1 ) ); - else - return arg2_1; - fi; - return; + local deduped_1_1; + deduped_1_1 := Length( arg2_1 ); + return CreateCapCategoryObjectWithAttributes( cat_1, Length, IdFunc( function ( ) + if deduped_1_1 = 0 then + return BigInt( 1 ); + else + return deduped_1_1; + fi; + return; + end )( ) ); end ######## @@ -881,7 +936,7 @@ end ######## function ( cat_1, T_1, P_1 ) - return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, T_1, AsList, [ ] ); + return CreateCapCategoryMorphismWithAttributes( cat_1, P_1, T_1, AsList, [ 0 .. Length( P_1 ) - 1 ] ); end ######## @@ -894,18 +949,18 @@ end function ( cat_1, objects_1, T_1, tau_1, P_1 ) local hoisted_1_1, hoisted_2_1, hoisted_3_1, deduped_5_1; deduped_5_1 := [ 0 .. Length( objects_1 ) - 1 ]; - hoisted_2_1 := List( objects_1, Length ); - hoisted_3_1 := List( deduped_5_1, function ( j_2 ) - return Product( hoisted_2_1{[ 1 .. j_2 ]} ); + hoisted_3_1 := List( tau_1, AsList ); + hoisted_1_1 := List( objects_1, Length ); + hoisted_2_1 := List( deduped_5_1, function ( j_2 ) + return Product( hoisted_1_1{[ 1 .. j_2 ]} ); end ); - hoisted_1_1 := List( tau_1, AsList ); return CreateCapCategoryMorphismWithAttributes( cat_1, T_1, P_1, AsList, List( [ 0 .. Length( T_1 ) - 1 ], function ( i_2 ) local hoisted_1_2; hoisted_1_2 := 1 + i_2; return Sum( deduped_5_1, function ( j_3 ) local deduped_1_3; deduped_1_3 := 1 + j_3; - return hoisted_1_1[deduped_1_3][hoisted_1_2] * hoisted_3_1[deduped_1_3]; + return hoisted_2_1[deduped_1_3] * hoisted_3_1[deduped_1_3][hoisted_1_2]; end ); end ) ); end @@ -966,7 +1021,7 @@ BindGlobal( "CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled", fun function ( ) - return CategoryOfSkeletalFinSets( ); + return CategoryOfSkeletalFinSetsWithMorphismsGivenByLists( ); end; diff --git a/init.g b/init.g index 8cffd4b..52481bf 100644 --- a/init.g +++ b/init.g @@ -10,6 +10,8 @@ ReadPackage( "FinSetsForCAP", "gap/FinSets.gd" ); ReadPackage( "FinSetsForCAP", "gap/SkeletalFinSets.gd" ); +ReadPackage( "FinSetsForCAP", "gap/SkeletalFinSetsEager.gd" ); + #= comment for Julia if IsPackageMarkedForLoading( "JuliaInterface", ">= 0.2" ) then # COVERAGE_IGNORE_NEXT_LINE diff --git a/read.g b/read.g index ee84fd6..dc35118 100644 --- a/read.g +++ b/read.g @@ -8,10 +8,14 @@ ReadPackage( "FinSetsForCAP", "gap/Tools.gi" ); ReadPackage( "FinSetsForCAP", "gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByListsPrecompiled.gi" ); +ReadPackage( "FinSetsForCAP", "gap/precompiled_categories/CategoryOfSkeletalFinSetsWithMorphismsGivenByFunctionsPrecompiled.gi" ); + ReadPackage( "FinSetsForCAP", "gap/FinSets.gi" ); ReadPackage( "FinSetsForCAP", "gap/SkeletalFinSets.gi" ); +ReadPackage( "FinSetsForCAP", "gap/SkeletalFinSetsEager.gi" ); + #= comment for Julia if IsPackageMarkedForLoading( "JuliaInterface", ">= 0.2" ) then # COVERAGE_IGNORE_NEXT_LINE