Skip to content

Commit 21e4a20

Browse files
authored
Merge pull request #78 from mohamed-barakat/CartesianEvaluationMorphismWithGivenSource
made CartesianEvaluationMorphismWithGivenSource purely functional
2 parents 8a24cb7 + 8a368ab commit 21e4a20

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
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-03",
13+
Version := "2021.12-04",
1414

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

gap/SkeletalFinSetsForCAP.gi

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ end );
689689
AddMonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject( SkeletalFinSets,
690690
function ( cat, M, injective_object )
691691

692-
return MapOfFinSets( M, List( M, x -> x ), injective_object );
692+
return MapOfFinSets( M, AsList( M ), injective_object );
693693

694694
end );
695695

@@ -721,13 +721,11 @@ end );
721721
##
722722
AddUniversalMorphismFromCoproductWithGivenCoproduct( SkeletalFinSets,
723723
function ( cat, L, test_object, tau, S )
724-
local T, cmp;
724+
local cmp;
725725

726-
T := Range( tau[1] );
727-
728-
cmp := Concatenation( List( [ 1 .. Length( tau ) ], x -> AsList( tau[x] ) ) );
729-
730-
return MapOfFinSets( S, cmp, T );
726+
cmp := Concatenation( List( tau, t -> AsList( t ) ) );
727+
728+
return MapOfFinSets( S, cmp, test_object );
731729

732730
end );
733731

@@ -804,12 +802,13 @@ end );
804802
##
805803
AddCartesianBraidingInverseWithGivenDirectProducts( SkeletalFinSets,
806804
function ( cat, MN, M, N, NM )
807-
local m, n;
805+
local n, mn;
808806

809-
m := Length( M );
810807
n := Length( N );
811808

812-
return MapOfFinSets( MN, List( AsList( MN ), k -> ( k-1 ) mod n * m + Int( ( k-1 ) / n ) + 1 ), NM );
809+
mn := Length( MN );
810+
811+
return MapOfFinSets( MN, List( [ 0 .. mn - 1 ] , i -> 1 + ( i mod mn ) + QuoInt( i, n ) ), NM );
813812

814813
end );
815814

@@ -848,13 +847,12 @@ end );
848847
##
849848
AddCartesianEvaluationMorphismWithGivenSource( SkeletalFinSets,
850849
function ( cat, M, N, HM_NxM )
851-
local HM_N, m;
850+
local m, n;
852851

853852
m := Length( M );
853+
n := Length( N );
854854

855-
HM_N := List( Tuples( AsList( N ), m ), x -> MapOfFinSets( M, x, N ) );
856-
857-
return MapOfFinSets( HM_NxM, List( Cartesian( HM_N, AsList( M ) ), fx -> fx[1](fx[2]) ), N );
855+
return MapOfFinSets( HM_NxM, List( [ 0 .. Length( HM_NxM ) - 1 ], i -> 1 + RemInt( QuoInt( QuoInt( i, m ), n^(m - RemInt( i, m ) - 1 ) ), n ) ), N );
858856

859857
end );
860858

gap/precompiled_categories/CategoryOfSkeletalFinSetsPrecompiled.gi

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ BindGlobal( "ADD_FUNCTIONS_FOR_CategoryOfSkeletalFinSetsPrecompiled", function (
1010

1111
########
1212
function ( cat_1, s_1, a_1, b_1, r_1 )
13-
local hoisted_1_1, hoisted_2_1;
14-
hoisted_2_1 := Length( a_1 );
15-
hoisted_1_1 := Length( b_1 );
16-
return MapOfFinSets( s_1, List( AsList( s_1 ), function ( k_2 )
17-
local deduped_1_2;
18-
deduped_1_2 := k_2 - 1;
19-
return deduped_1_2 mod hoisted_1_1 * hoisted_2_1 + Int( deduped_1_2 / hoisted_1_1 ) + 1;
13+
local hoisted_1_1, hoisted_2_1, deduped_3_1;
14+
deduped_3_1 := Length( s_1 );
15+
hoisted_2_1 := Length( b_1 );
16+
hoisted_1_1 := deduped_3_1;
17+
return MapOfFinSets( s_1, List( [ 0 .. deduped_3_1 - 1 ], function ( i_2 )
18+
return 1 + i_2 mod hoisted_1_1 + QUO_INT( i_2, hoisted_2_1 );
2019
end ), r_1 );
2120
end
2221
########
@@ -28,10 +27,11 @@ end
2827

2928
########
3029
function ( cat_1, a_1, b_1, s_1 )
31-
return MapOfFinSets( s_1, List( Cartesian( List( Tuples( AsList( b_1 ), Length( a_1 ) ), function ( x_2 )
32-
return MapOfFinSets( a_1, x_2, b_1 );
33-
end ), AsList( a_1 ) ), function ( fx_2 )
34-
return fx_2[1]( fx_2[2] );
30+
local hoisted_1_1, hoisted_2_1;
31+
hoisted_2_1 := Length( b_1 );
32+
hoisted_1_1 := Length( a_1 );
33+
return MapOfFinSets( s_1, List( [ 0 .. Length( s_1 ) - 1 ], function ( i_2 )
34+
return 1 + REM_INT( QUO_INT( QUO_INT( i_2, hoisted_1_1 ), hoisted_2_1 ^ (hoisted_1_1 - REM_INT( i_2, hoisted_1_1 ) - 1) ), hoisted_2_1 );
3535
end ), b_1 );
3636
end
3737
########
@@ -567,9 +567,7 @@ end
567567

568568
########
569569
function ( cat_1, A_1, I_1 )
570-
return MapOfFinSets( A_1, List( A_1, function ( x_2 )
571-
return x_2;
572-
end ), I_1 );
570+
return MapOfFinSets( A_1, AsList( A_1 ), I_1 );
573571
end
574572
########
575573

@@ -710,9 +708,9 @@ end
710708

711709
########
712710
function ( cat_1, objects_1, T_1, tau_1, P_1 )
713-
return MapOfFinSets( P_1, Concatenation( List( [ 1 .. Length( tau_1 ) ], function ( x_2 )
714-
return AsList( tau_1[x_2] );
715-
end ) ), Range( tau_1[1] ) );
711+
return MapOfFinSets( P_1, Concatenation( List( tau_1, function ( t_2 )
712+
return AsList( t_2 );
713+
end ) ), T_1 );
716714
end
717715
########
718716

0 commit comments

Comments
 (0)