Skip to content

Commit 8a30559

Browse files
made ProjectionInFactorOfDirectProductWithGivenDirectProduct purely functional
for SkeletalFinSets
1 parent 35297e9 commit 8a30559

File tree

4 files changed

+29
-24
lines changed

4 files changed

+29
-24
lines changed

PackageInfo.g

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SetPackageInfo( rec(
1010

1111
PackageName := "FinSetsForCAP",
1212
Subtitle := "The elementary topos of (skeletal) finite sets",
13-
Version := "2021.12-04",
13+
Version := "2021.12-05",
1414

1515
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
1616
License := "GPL-2.0-or-later",

examples/PrecompileCategoryOfSkeletalFinSets.g

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ CapJitPrecompileCategoryAndCompareResult(
2525
uncompiled_SkeletalFinSets
2626
),
2727
[
28-
"ProjectionInFactorOfDirectProduct", # uses CAP prepare functions
2928
"UniversalMorphismIntoDirectProduct", # uses CAP prepare functions
3029
]
3130
)

gap/SkeletalFinSetsForCAP.gi

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -528,32 +528,19 @@ AddDirectProduct( SkeletalFinSets,
528528
end );
529529

530530
##
531-
AddProjectionInFactorOfDirectProduct( SkeletalFinSets, CAPOperationPrepareFunction( "ProjectionInFactorOfBinaryDirectProductToProjectionInFactorOfDirectProduct", SkeletalFinSets, function ( cat, M, N, pos )
532-
local S, T, n, imgs, i;
531+
AddProjectionInFactorOfDirectProductWithGivenDirectProduct( SkeletalFinSets,
532+
function ( cat, D, k, P )
533+
local T, l, a;
533534

534-
S := DirectProduct( [ M, N ] );
535-
if pos = 1 then
536-
T := M;
537-
else
538-
T := N;
539-
fi;
535+
T := D[k];
540536

541-
n := Length( N );
537+
l := Length( T );
542538

543-
imgs := [ ];
544-
545-
for i in AsList( S ) do
546-
if pos = 2 then
547-
Add( imgs, (i - 1) mod n );
548-
else
549-
Add( imgs, Int( (i - 1) / n ) );
550-
fi;
551-
od;
539+
a := Product( D{[ k + 1 .. Length( D ) ]}, M -> Length( M ) );
552540

553-
imgs := List( imgs, img -> img + 1 );
554-
555-
return MapOfFinSets( S, imgs, T );
556-
end ) );
541+
return MapOfFinSets( P, List( [ 0 .. Length( P ) - 1 ], i -> 1 + RemInt( QuoInt( i, a ), l ) ), T );
542+
543+
end );
557544

558545
##
559546
AddUniversalMorphismIntoDirectProduct( SkeletalFinSets, CAPOperationPrepareFunction( "UniversalMorphismIntoBinaryDirectProductToUniversalMorphismIntoDirectProduct", SkeletalFinSets, function ( cat, tau1, tau2 )

gap/precompiled_categories/CategoryOfSkeletalFinSetsPrecompiled.gi

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,25 @@ end
634634

635635
, 100 );
636636

637+
##
638+
AddProjectionInFactorOfDirectProductWithGivenDirectProduct( cat,
639+
640+
########
641+
function ( cat_1, objects_1, k_1, P_1 )
642+
local hoisted_1_1, hoisted_2_1, deduped_3_1;
643+
deduped_3_1 := objects_1[k_1];
644+
hoisted_2_1 := Length( deduped_3_1 );
645+
hoisted_1_1 := Product( objects_1{[ k_1 + 1 .. Length( objects_1 ) ]}, function ( M_2 )
646+
return Length( M_2 );
647+
end );
648+
return MapOfFinSets( P_1, List( [ 0 .. Length( P_1 ) - 1 ], function ( i_2 )
649+
return 1 + REM_INT( QUO_INT( i_2, hoisted_1_1 ), hoisted_2_1 );
650+
end ), deduped_3_1 );
651+
end
652+
########
653+
654+
, 100 );
655+
637656
##
638657
AddProjectionOntoCoequalizerWithGivenCoequalizer( cat,
639658

0 commit comments

Comments
 (0)