Skip to content

Commit 3b1b8e3

Browse files
made UniversalMorphismIntoDirectProductWithGivenDirectProduct purely functional
for SkeletalFinSets
1 parent 8a30559 commit 3b1b8e3

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
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-05",
13+
Version := "2021.12-06",
1414

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

examples/PrecompileCategoryOfSkeletalFinSets.g

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,12 @@ given_arguments := [ ];;
1212
compiled_category_name := "CategoryOfSkeletalFinSetsPrecompiled";;
1313
package_name := "FinSetsForCAP";;
1414

15-
uncompiled_SkeletalFinSets :=
16-
CategoryOfSkeletalFinSets( : no_precompiled_code := true );;
17-
1815
CapJitPrecompileCategoryAndCompareResult(
1916
category_constructor,
2017
given_arguments,
2118
package_name,
2219
compiled_category_name
23-
: operations := Difference(
24-
ListPrimitivelyInstalledOperationsOfCategory(
25-
uncompiled_SkeletalFinSets
26-
),
27-
[
28-
"UniversalMorphismIntoDirectProduct", # uses CAP prepare functions
29-
]
30-
)
20+
: operations := "primitive"
3121
);;
3222

3323
CategoryOfSkeletalFinSetsPrecompiled( );

gap/SkeletalFinSetsForCAP.gi

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -543,23 +543,21 @@ AddProjectionInFactorOfDirectProductWithGivenDirectProduct( SkeletalFinSets,
543543
end );
544544

545545
##
546-
AddUniversalMorphismIntoDirectProduct( SkeletalFinSets, CAPOperationPrepareFunction( "UniversalMorphismIntoBinaryDirectProductToUniversalMorphismIntoDirectProduct", SkeletalFinSets, function ( cat, tau1, tau2 )
547-
local S, T, n, imgs, i;
546+
AddUniversalMorphismIntoDirectProductWithGivenDirectProduct( SkeletalFinSets,
547+
function ( cat, D, T, tau, P )
548+
local l, d, dd, taus;
548549

549-
S := Source( tau1 );
550-
T := DirectProduct( [ Range( tau1 ), Range( tau2 ) ] );
550+
l := Length( D );
551551

552-
n := Length( Range( tau2 ) );
552+
d := List( D, x -> Length( x ) );
553553

554-
imgs := [ ];
554+
dd := List( [ 1 .. l ], i -> Product( d{[ i + 1 .. l ]} ) );
555555

556-
for i in AsList( S ) do
557-
Add( imgs, (AsList( tau1 )[i] - 1) * n + AsList( tau2 )[i] );
558-
od;
556+
taus := List( tau, x -> AsList( x ) );
559557

560-
return MapOfFinSets( S, imgs, T );
558+
return MapOfFinSets( T, List( AsList( T ), i -> 1 + Sum( [ 1 .. l ], j -> ( taus[j][i] - 1 ) * dd[j] ) ), P );
561559

562-
end ) );
560+
end );
563561

564562
##
565563
AddEqualizer( SkeletalFinSets,

gap/precompiled_categories/CategoryOfSkeletalFinSetsPrecompiled.gi

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,35 @@ end
746746

747747
, 100 );
748748

749+
##
750+
AddUniversalMorphismIntoDirectProductWithGivenDirectProduct( cat,
751+
752+
########
753+
function ( cat_1, objects_1, T_1, tau_1, P_1 )
754+
local hoisted_1_1, hoisted_2_1, hoisted_3_1, hoisted_4_1, hoisted_5_1, deduped_6_1, deduped_7_1;
755+
deduped_7_1 := Length( objects_1 );
756+
deduped_6_1 := [ 1 .. deduped_7_1 ];
757+
hoisted_5_1 := deduped_6_1;
758+
hoisted_3_1 := List( objects_1, function ( x_2 )
759+
return Length( x_2 );
760+
end );
761+
hoisted_2_1 := deduped_7_1;
762+
hoisted_4_1 := List( deduped_6_1, function ( i_2 )
763+
return Product( hoisted_3_1{[ i_2 + 1 .. hoisted_2_1 ]} );
764+
end );
765+
hoisted_1_1 := List( tau_1, function ( x_2 )
766+
return AsList( x_2 );
767+
end );
768+
return MapOfFinSets( T_1, List( AsList( T_1 ), function ( i_2 )
769+
return 1 + Sum( hoisted_5_1, function ( j_3 )
770+
return (hoisted_1_1[j_3][i_2] - 1) * hoisted_4_1[j_3];
771+
end );
772+
end ), P_1 );
773+
end
774+
########
775+
776+
, 100 );
777+
749778
##
750779
AddUniversalMorphismIntoEqualizerWithGivenEqualizer( cat,
751780

0 commit comments

Comments
 (0)