Skip to content

Commit b388d0a

Browse files
Merge pull request #1787 from mohamed-barakat/LinearClosure
start making LinearClosure compilable
2 parents 40b2bbe + 6da9f66 commit b388d0a

File tree

3 files changed

+119
-85
lines changed

3 files changed

+119
-85
lines changed

LinearClosuresForCAP/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 := "LinearClosuresForCAP",
1212
Subtitle := "Linear closures",
13-
Version := "2025.07-03",
13+
Version := "2025.08-01",
1414
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
1515
License := "GPL-2.0-or-later",
1616

LinearClosuresForCAP/gap/HomomorphismStructure.gi

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,16 @@ InstallGlobalFunction( INSTALL_HOMOMORPHISM_STRUCTURE_FOR_LINEAR_CLOSURE,
167167

168168
range_finset := FinSet( finsets, size );
169169

170-
return LinearClosureMorphism(
171-
a,
172-
EntriesOfHomalgMatrix( UnderlyingMatrix( mor ) ),
173-
List( [ 0 .. size - 1 ], i ->
174-
InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism(
175-
a_und, b_und, MapOfFinSets( t_finsets, [ i ], range_finset )
176-
)
177-
),
178-
b
179-
);
180-
170+
return MorphismConstructor( cat,
171+
a,
172+
Pair( EntriesOfHomalgMatrix( UnderlyingMatrix( mor ) ),
173+
List( [ 0 .. size - 1 ], i ->
174+
InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism(
175+
a_und,
176+
b_und,
177+
MapOfFinSets( t_finsets, [ i ], range_finset ) ) ) ),
178+
b );
179+
181180
end );
182181

183182
fi;

LinearClosuresForCAP/gap/LinearClosure.gi

Lines changed: 108 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ InstallGlobalFunction( LINEAR_CLOSURE_CONSTRUCTOR_USING_CategoryOfRows,
6666
category!.compiler_hints := rec(
6767
category_attribute_names := [
6868
"UnderlyingCategory",
69+
"CommutativeRingOfLinearCategory",
6970
],
7071
);
7172

@@ -412,7 +413,7 @@ end );
412413

413414
InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
414415
function( rows, category )
415-
local ring, underlying_category, sorting_function, mul_coeffs, mul_supp, with_nf,
416+
local ring, underlying_category, sorting_function, with_nf,
416417
equality_func, finsets, t_obj, t_finsets, FunctorMor, FunctorObj, cocycle;
417418

418419
if not IsCategoryOfRows( rows ) then
@@ -446,14 +447,28 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
446447
return UnderlyingOriginalObject( object );
447448

448449
end );
449-
450-
##
451-
AddMorphismConstructor( category,
452-
function( cat, source, pair, range )
450+
451+
if with_nf then
453452

454-
return LinearClosureMorphismNC( cat, source, pair[1], pair[2], range );
453+
##
454+
AddMorphismConstructor( category,
455+
function( cat, source, pair, range )
456+
457+
return LinearClosureMorphism( cat, source, pair[1], pair[2], range );
458+
459+
end );
460+
461+
else
455462

456-
end );
463+
##
464+
AddMorphismConstructor( category,
465+
function( cat, source, pair, range )
466+
467+
return LinearClosureMorphismNC( cat, source, pair[1], pair[2], range );
468+
469+
end );
470+
471+
fi;
457472

458473
##
459474
AddMorphismDatum( category,
@@ -464,52 +479,74 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
464479
end );
465480

466481
##
467-
AddIsEqualForObjects( category, {cat, a, b} -> IsEqualForObjects( UnderlyingOriginalObject( a ), UnderlyingOriginalObject( b ) ) );
482+
AddIsEqualForObjects( category,
483+
function( cat, a, b )
484+
485+
return IsEqualForObjects( UnderlyingCategory( cat ), UnderlyingOriginalObject( a ), UnderlyingOriginalObject( b ) );
486+
487+
end );
468488

469-
equality_func := function( alpha, beta, equal_or_cong )
470-
local coeffs_a, coeffs_b, supp_a, supp_b, size;
489+
##
490+
AddIsEqualForMorphisms( category,
491+
function( cat, alpha, beta )
492+
local coeffs_a, coeffs_b, supp_a, supp_b, size_coeffs_a;
471493

472494
coeffs_a := CoefficientsList( alpha );
473495

474496
coeffs_b := CoefficientsList( beta );
475497

476-
size := Length( coeffs_a );
498+
size_coeffs_a := Length( coeffs_a );
477499

478-
if size <> Length( coeffs_b ) then
479-
return false;
480-
fi;
481-
482-
return ForAll( [ 1 .. size ], i -> equal_or_cong( SupportMorphisms( alpha )[i], SupportMorphisms( beta )[i] ) ) and
483-
coeffs_a = coeffs_b;
500+
return size_coeffs_a = Length( coeffs_b ) and
501+
ForAll( [ 1 .. size_coeffs_a ], i ->
502+
IsEqualForMorphisms( UnderlyingCategory( cat ), SupportMorphisms( alpha )[i], SupportMorphisms( beta )[i] ) ) and
503+
coeffs_a = coeffs_b;
484504

485-
end;
486-
487-
##
488-
AddIsEqualForMorphisms( category, {cat, alpha, beta} -> equality_func( alpha, beta, IsEqualForMorphisms ) );
505+
end );
489506

490507
if with_nf then
491508

492509
##
493-
AddIsCongruentForMorphisms( category, {cat, alpha, beta} -> equality_func( alpha, beta, IsCongruentForMorphisms ) );
510+
AddIsCongruentForMorphisms( category,
511+
function( cat, alpha, beta )
512+
local coeffs_a, coeffs_b, supp_a, supp_b, size_coeffs_a;
513+
514+
coeffs_a := CoefficientsList( alpha );
515+
516+
coeffs_b := CoefficientsList( beta );
517+
518+
size_coeffs_a := Length( coeffs_a );
519+
520+
return size_coeffs_a = Length( coeffs_b ) and
521+
ForAll( [ 1 .. size_coeffs_a ], i ->
522+
IsCongruentForMorphisms( UnderlyingCategory( cat ), SupportMorphisms( alpha )[i], SupportMorphisms( beta )[i] ) ) and
523+
coeffs_a = coeffs_b;
524+
525+
end );
494526

495527
else
496528

497529
##
498530
AddIsCongruentForMorphisms( category,
499-
function( cat, alpha, beta )
500-
501-
return IsZeroForMorphisms( SubtractionForMorphisms( alpha, beta ) );
502-
531+
function( cat, alpha, beta )
532+
533+
return IsZeroForMorphisms( cat, SubtractionForMorphisms( cat, alpha, beta ) );
534+
503535
end );
504536

505537
fi;
506538

507539
##
508-
AddIsWellDefinedForObjects( category, {cat, x} -> IsIdenticalObj( underlying_category, CapCategory( UnderlyingOriginalObject( x ) ) ) );
509-
540+
AddIsWellDefinedForObjects( category,
541+
function( cat, x )
542+
543+
return IsIdenticalObj( underlying_category, CapCategory( UnderlyingOriginalObject( x ) ) );
544+
545+
end );
546+
510547
##
511548
AddIsWellDefinedForMorphisms( category,
512-
function( cat, alpha )
549+
function( cat, alpha )
513550
local coeffs, supp, size, s, i;
514551

515552
coeffs := CoefficientsList( alpha );
@@ -561,22 +598,18 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
561598
end );
562599

563600
##
564-
mul_supp := {alpha, beta} -> PreCompose( alpha, beta );
565-
566-
mul_coeffs := {a,b} -> a * b;
567-
568601
if not IsBound( category!.cocycle ) then
569602

570603
##
571604
AddPreCompose( category,
572605
function( cat, alpha, beta )
573606
local coeffs, supp;
574607

575-
coeffs := ListX( CoefficientsList( alpha ), CoefficientsList( beta ), mul_coeffs );
608+
coeffs := ListX( CoefficientsList( alpha ), CoefficientsList( beta ), { a,b } -> a * b );
576609

577-
supp := ListX( SupportMorphisms( alpha ), SupportMorphisms( beta ), mul_supp );
610+
supp := ListX( SupportMorphisms( alpha ), SupportMorphisms( beta ), { alpha, beta } -> PreCompose( underlying_category, alpha, beta ) );
578611

579-
return LinearClosureMorphism( Source( alpha ), coeffs, supp, Range( beta ) );
612+
return MorphismConstructor( cat, Source( alpha ), Pair( coeffs, supp ), Range( beta ) );
580613

581614
end );
582615

@@ -605,9 +638,9 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
605638

606639
for b in [ 1 .. Length( coeffs_beta ) ] do
607640

608-
gamma := mul_supp( supp_alpha[a], supp_beta[b] );
641+
gamma := PreCompose( supp_alpha[a], supp_beta[b] );
609642

610-
coeff := mul_coeffs( coeffs_alpha[a], coeffs_beta[b] ) * cocycle( supp_alpha[a], supp_beta[b], gamma );
643+
coeff := ( coeffs_alpha[a] * coeffs_beta[b] ) * cocycle( supp_alpha[a], supp_beta[b], gamma );
611644

612645
Add( supp, gamma );
613646

@@ -617,7 +650,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
617650

618651
od;
619652

620-
return LinearClosureMorphism( Source( alpha ), coeffs, supp, Range( beta ) );
653+
return MorphismConstructor( cat, Source( alpha ), Pair( coeffs, supp ), Range( beta ) );
621654

622655
end );
623656

@@ -643,12 +676,11 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
643676

644677
end );
645678

646-
647679
if with_nf then
648680

649681
##
650682
AddIsZeroForMorphisms( category,
651-
function( cat, alpha )
683+
function( cat, alpha )
652684

653685
return IsEmpty( CoefficientsList( alpha ) );
654686

@@ -669,45 +701,49 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
669701
##
670702
AddAdditionForMorphisms( category,
671703
function( cat, alpha, beta )
672-
return LinearClosureMorphism(
673-
Source( alpha ),
674-
Concatenation( CoefficientsList( alpha ), CoefficientsList( beta ) ),
675-
Concatenation( SupportMorphisms( alpha ), SupportMorphisms( beta ) ),
676-
Range( alpha )
677-
);
704+
705+
return MorphismConstructor( cat,
706+
Source( alpha ),
707+
Pair( Concatenation( CoefficientsList( alpha ), CoefficientsList( beta ) ),
708+
Concatenation( SupportMorphisms( alpha ), SupportMorphisms( beta ) ) ),
709+
Range( alpha ) );
710+
678711
end );
679712

680713
##
681714
AddAdditiveInverseForMorphisms( category,
682715
function( cat, alpha )
683-
return LinearClosureMorphism(
684-
Source( alpha ),
685-
List( CoefficientsList( alpha ), c -> MinusOne( ring ) * c ),
686-
SupportMorphisms( alpha ),
687-
Range( alpha )
688-
);
716+
717+
return MorphismConstructor( cat,
718+
Source( alpha ),
719+
Pair( List( CoefficientsList( alpha ), c -> MinusOne( ring ) * c ),
720+
SupportMorphisms( alpha ) ),
721+
Range( alpha ) );
722+
689723
end );
690724

691725
##
692726
AddSubtractionForMorphisms( category,
693727
function( cat, alpha, beta )
694-
return LinearClosureMorphism(
695-
Source( alpha ),
696-
Concatenation( CoefficientsList( alpha ), List( CoefficientsList( beta ), c -> MinusOne( ring ) * c ) ),
697-
Concatenation( SupportMorphisms( alpha ), SupportMorphisms( beta ) ),
698-
Range( alpha )
699-
);
728+
729+
return MorphismConstructor( cat,
730+
Source( alpha ),
731+
Pair( Concatenation( CoefficientsList( alpha ), List( CoefficientsList( beta ), c -> MinusOne( ring ) * c ) ),
732+
Concatenation( SupportMorphisms( alpha ), SupportMorphisms( beta ) ) ),
733+
Range( alpha ) );
734+
700735
end );
701736

702737
##
703738
AddMultiplyWithElementOfCommutativeRingForMorphisms( category,
704-
function( cat, r, alpha )
705-
return LinearClosureMorphism(
706-
Source( alpha ),
707-
List( CoefficientsList( alpha ), c -> r * c ),
708-
SupportMorphisms( alpha ),
709-
Range( alpha )
710-
);
739+
function( cat, r, alpha )
740+
741+
return MorphismConstructor( cat,
742+
Source( alpha ),
743+
Pair( List( CoefficientsList( alpha ), c -> r * c ),
744+
SupportMorphisms( alpha ) ),
745+
Range( alpha ) );
746+
711747
end );
712748

713749
if not with_nf then
@@ -726,11 +762,11 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
726762

727763
##
728764
AddSetOfObjectsOfCategory( category,
729-
function( cat )
730-
731-
return List( SetOfObjectsOfCategory( underlying_category ),
732-
obj -> LinearClosureObject( category, obj ) );
733-
765+
function( cat )
766+
767+
return List( SetOfObjectsOfCategory( underlying_category ),
768+
obj -> LinearClosureObject( category, obj ) );
769+
734770
end );
735771

736772
fi;
@@ -740,8 +776,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,
740776
if with_nf and
741777
HasIsEquippedWithHomomorphismStructure( underlying_category ) and
742778
IsEquippedWithHomomorphismStructure( underlying_category ) and
743-
IsPackageMarkedForLoading( "FinSetsForCAP", ">= 2023.07-03" )
744-
then
779+
IsPackageMarkedForLoading( "FinSetsForCAP", ">= 2023.07-03" ) then
745780

746781
INSTALL_HOMOMORPHISM_STRUCTURE_FOR_LINEAR_CLOSURE( category, rows );
747782

0 commit comments

Comments
 (0)