Skip to content

Commit 7fc8930

Browse files
authored
Merge pull request #80 from zickgraf/master
Resolve FinSet and MapOfFinSets for skeletal finite sets
2 parents 7fa1cd0 + 2dcaa55 commit 7fc8930

File tree

3 files changed

+164
-115
lines changed

3 files changed

+164
-115
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-06",
13+
Version := "2021.12-07",
1414

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

gap/SkeletalFinSetsForCAP.gi

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ InstallMethod( CategoryOfSkeletalFinSets,
2121

2222
SetIsElementaryTopos( cat, true );
2323

24-
AddObjectRepresentation( cat, IsSkeletalFiniteSet and HasLength and HasAsList );
24+
AddObjectRepresentation( cat, IsSkeletalFiniteSet and HasLength );
2525

2626
AddMorphismRepresentation( cat, IsSkeletalFiniteSetMap and HasAsList );
2727

@@ -43,25 +43,32 @@ InstallMethod( CategoryOfSkeletalFinSets,
4343
end );
4444

4545
##
46-
InstallMethod( FinSetOp,
46+
InstallMethodForCompilerForCAP( FinSetOp,
4747
[ IsCategoryOfSkeletalFinSets, IsInt ],
4848

4949
function ( cat, n )
5050
local int;
5151

52-
int := rec( );
52+
int := ObjectifyObjectForCAPWithAttributes( rec( ), cat, Length, n );
5353

54-
ObjectifyObjectForCAPWithAttributes( int, cat,
55-
Length, n,
56-
AsList, [ 1 .. n ]
57-
);
58-
54+
#% CAP_JIT_DROP_NEXT_STATEMENT
5955
Assert( 4, IsWellDefined( int ) );
6056

6157
return int;
6258

6359
end );
6460

61+
##
62+
InstallMethod( AsList,
63+
"for a CAP skeletal finite set",
64+
[ IsSkeletalFiniteSet ],
65+
66+
function ( s )
67+
68+
return [ 1 .. Length( s ) ];
69+
70+
end );
71+
6572
##
6673
InstallMethod( ListOp,
6774
"for a CAP skeletal finite set and a function",
@@ -80,16 +87,26 @@ InstallMethod( MapOfFinSets,
8087
[ IsSkeletalFiniteSet, IsList, IsSkeletalFiniteSet ],
8188

8289
function ( s, G, t )
83-
local map;
8490

85-
map := rec( );
91+
return MapOfFinSets( CapCategory( s ), s, G, t );
8692

87-
ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( map, CapCategory( s ),
93+
end );
94+
95+
##
96+
InstallOtherMethodForCompilerForCAP( MapOfFinSets,
97+
"for a category of skeletal finite sets, two CAP skeletal finite sets and a list",
98+
[ IsCategoryOfSkeletalFinSets, IsSkeletalFiniteSet, IsList, IsSkeletalFiniteSet ],
99+
100+
function ( cat, s, G, t )
101+
local map;
102+
103+
map := ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( rec( ), cat,
88104
s,
89105
t,
90106
AsList, G
91107
);
92108

109+
#% CAP_JIT_DROP_NEXT_STATEMENT
93110
Assert( 4, IsWellDefined( map ) );
94111

95112
return map;
@@ -252,7 +269,7 @@ end );
252269
AddMorphismConstructor( SkeletalFinSets,
253270
function ( SkeletalFinSets, source, map, range )
254271

255-
return MapOfFinSets( source, map, range );
272+
return MapOfFinSets( SkeletalFinSets, source, map, range );
256273

257274
end );
258275

@@ -320,7 +337,7 @@ end );
320337
AddIdentityMorphism( SkeletalFinSets,
321338
function ( cat, n )
322339

323-
return MapOfFinSets( n, [ 1 .. Length( n ) ], n );
340+
return MapOfFinSets( cat, n, [ 1 .. Length( n ) ], n );
324341

325342
end );
326343

@@ -337,7 +354,7 @@ AddPreCompose( SkeletalFinSets,
337354

338355
cmp := List( s, i -> im_post[ im_pre[i] ] );
339356

340-
return MapOfFinSets( s, cmp, t );
357+
return MapOfFinSets( cat, s, cmp, t );
341358

342359
end );
343360

@@ -423,7 +440,7 @@ AddLift( SkeletalFinSets,
423440
gg := AsList( g );
424441
ff := AsList( f );
425442

426-
return MapOfFinSets( S, List( AsList( S ), x -> Position( gg, ff[x] ) ), T );
443+
return MapOfFinSets( cat, S, List( AsList( S ), x -> Position( gg, ff[x] ) ), T );
427444

428445
end );
429446

@@ -459,15 +476,15 @@ AddColift( SkeletalFinSets,
459476
return gg[Position( ff, y )];
460477
end;
461478

462-
return MapOfFinSets( S, List( AsList( S ), chi ), T );
479+
return MapOfFinSets( cat, S, List( AsList( S ), chi ), T );
463480

464481
end );
465482

466483
##
467484
AddImageEmbeddingWithGivenImageObject( SkeletalFinSets,
468485
function ( cat, phi, image )
469486

470-
return MapOfFinSets( image, Set( AsList( phi ) ), Range( phi ) );
487+
return MapOfFinSets( cat, image, Set( AsList( phi ) ), Range( phi ) );
471488

472489
end );
473490

@@ -480,7 +497,7 @@ AddCoastrictionToImageWithGivenImageObject( SkeletalFinSets,
480497

481498
L := List( G, l -> Position( Set( G ), l ) );
482499

483-
pi := MapOfFinSets( Source( phi ), L, image_object );
500+
pi := MapOfFinSets( cat, Source( phi ), L, image_object );
484501

485502
#% CAP_JIT_DROP_NEXT_STATEMENT
486503
Assert( 3, IsEpimorphism( cat, pi ) );
@@ -515,7 +532,7 @@ AddUniversalMorphismIntoTerminalObjectWithGivenTerminalObject( SkeletalFinSets,
515532

516533
M := AsList( m );
517534

518-
return MapOfFinSets( m, List( M, a -> Length( t ) ), t );
535+
return MapOfFinSets( cat, m, List( M, a -> Length( t ) ), t );
519536

520537
end );
521538

@@ -538,7 +555,7 @@ AddProjectionInFactorOfDirectProductWithGivenDirectProduct( SkeletalFinSets,
538555

539556
a := Product( D{[ k + 1 .. Length( D ) ]}, M -> Length( M ) );
540557

541-
return MapOfFinSets( P, List( [ 0 .. Length( P ) - 1 ], i -> 1 + RemInt( QuoInt( i, a ), l ) ), T );
558+
return MapOfFinSets( cat, P, List( [ 0 .. Length( P ) - 1 ], i -> 1 + RemInt( QuoInt( i, a ), l ) ), T );
542559

543560
end );
544561

@@ -555,7 +572,7 @@ AddUniversalMorphismIntoDirectProductWithGivenDirectProduct( SkeletalFinSets,
555572

556573
taus := List( tau, x -> AsList( x ) );
557574

558-
return MapOfFinSets( T, List( AsList( T ), i -> 1 + Sum( [ 1 .. l ], j -> ( taus[j][i] - 1 ) * dd[j] ) ), P );
575+
return MapOfFinSets( cat, T, List( AsList( T ), i -> 1 + Sum( [ 1 .. l ], j -> ( taus[j][i] - 1 ) * dd[j] ) ), P );
559576

560577
end );
561578

@@ -588,7 +605,7 @@ AddEmbeddingOfEqualizerWithGivenEqualizer( SkeletalFinSets,
588605

589606
cmp := Filtered( AsList( s ), x -> ForAll( D2, fj -> f1( x ) = fj( x ) ) );
590607

591-
return MapOfFinSets( E, cmp, s );
608+
return MapOfFinSets( cat, E, cmp, s );
592609

593610
end );
594611

@@ -603,7 +620,7 @@ AddUniversalMorphismIntoEqualizerWithGivenEqualizer( SkeletalFinSets,
603620

604621
Eq := Filtered( AsList( s ), x -> ForAll( D, fj -> f1( x ) = fj( x ) ) );
605622

606-
return MapOfFinSets( Source( tau ), List( Source( tau ), x -> Position( Eq, tau( x ) ) ), E );
623+
return MapOfFinSets( cat, Source( tau ), List( Source( tau ), x -> Position( Eq, tau( x ) ) ), E );
607624

608625
end );
609626

@@ -630,7 +647,7 @@ end );
630647
AddUniversalMorphismFromInitialObjectWithGivenInitialObject( SkeletalFinSets,
631648
function ( cat, m, I )
632649

633-
return MapOfFinSets( I, [ ], m );
650+
return MapOfFinSets( cat, I, [ ], m );
634651

635652
end );
636653

@@ -674,7 +691,7 @@ end );
674691
AddMonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject( SkeletalFinSets,
675692
function ( cat, M, injective_object )
676693

677-
return MapOfFinSets( M, AsList( M ), injective_object );
694+
return MapOfFinSets( cat, M, AsList( M ), injective_object );
678695

679696
end );
680697

@@ -699,7 +716,7 @@ AddInjectionOfCofactorOfCoproductWithGivenCoproduct( SkeletalFinSets,
699716

700717
cmp := List( s, x -> sum + x );
701718

702-
return MapOfFinSets( s, cmp, coproduct );
719+
return MapOfFinSets( cat, s, cmp, coproduct );
703720

704721
end );
705722

@@ -710,7 +727,7 @@ AddUniversalMorphismFromCoproductWithGivenCoproduct( SkeletalFinSets,
710727

711728
cmp := Concatenation( List( tau, t -> AsList( t ) ) );
712729

713-
return MapOfFinSets( S, cmp, test_object );
730+
return MapOfFinSets( cat, S, cmp, test_object );
714731

715732
end );
716733

@@ -735,7 +752,7 @@ AddProjectionOntoCoequalizerWithGivenCoequalizer( SkeletalFinSets,
735752

736753
cmp := List( cmp, x -> Position( Cq, x ) );
737754

738-
return MapOfFinSets( s, cmp, C );
755+
return MapOfFinSets( cat, s, cmp, C );
739756

740757
end );
741758

@@ -746,7 +763,7 @@ AddUniversalMorphismFromCoequalizerWithGivenCoequalizer( SkeletalFinSets,
746763

747764
Cq := SKELETAL_FIN_SETS_ExplicitCoequalizer( D );
748765

749-
return MapOfFinSets( C, List( Cq, x -> tau( x[1] ) ), Range( tau ) );
766+
return MapOfFinSets( cat, C, List( Cq, x -> tau( x[1] ) ), Range( tau ) );
750767

751768
end );
752769

@@ -793,7 +810,7 @@ AddCartesianBraidingInverseWithGivenDirectProducts( SkeletalFinSets,
793810

794811
mn := Length( MN );
795812

796-
return MapOfFinSets( MN, List( [ 0 .. mn - 1 ] , i -> 1 + ( i mod mn ) + QuoInt( i, n ) ), NM );
813+
return MapOfFinSets( cat, MN, List( [ 0 .. mn - 1 ] , i -> 1 + ( i mod mn ) + QuoInt( i, n ) ), NM );
797814

798815
end );
799816

@@ -822,10 +839,10 @@ AddExponentialOnMorphismsWithGivenExponentials( SkeletalFinSets,
822839
a := Length( A );
823840
B := Range( beta );
824841

825-
S_int := List( Tuples( AsList( N ), m ), x -> MapOfFinSets( M, x, N ) );
826-
T_int := List( Tuples( AsList( B ), a ), x -> MapOfFinSets( A, x, B ) );
842+
S_int := List( Tuples( AsList( N ), m ), x -> MapOfFinSets( cat, M, x, N ) );
843+
T_int := List( Tuples( AsList( B ), a ), x -> MapOfFinSets( cat, A, x, B ) );
827844

828-
return MapOfFinSets( S, List( List( S_int, f -> PreComposeList( cat, [ alpha, f, beta ] ) ), f -> Position( T_int, f ) ), T );
845+
return MapOfFinSets( cat, S, List( List( S_int, f -> PreComposeList( cat, [ alpha, f, beta ] ) ), f -> Position( T_int, f ) ), T );
829846

830847
end );
831848

@@ -837,7 +854,7 @@ AddCartesianEvaluationMorphismWithGivenSource( SkeletalFinSets,
837854
m := Length( M );
838855
n := Length( N );
839856

840-
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 );
857+
return MapOfFinSets( cat, HM_NxM, List( [ 0 .. Length( HM_NxM ) - 1 ], i -> 1 + RemInt( QuoInt( QuoInt( i, m ), n^(m - RemInt( i, m ) - 1 ) ), n ) ), N );
841858

842859
end );
843860

@@ -867,7 +884,7 @@ AddClassifyingMorphismOfSubobjectWithGivenSubobjectClassifier( SkeletalFinSets,
867884

868885
end );
869886

870-
return MapOfFinSets( range, images, Omega );
887+
return MapOfFinSets( cat, range, images, Omega );
871888

872889
end );
873890

0 commit comments

Comments
 (0)