Skip to content

Commit cda804d

Browse files
committed
fix a bug in Lift/Colift methods in ModulePresentationsForCAP
resolves #1744 Bump ModulePresentationsForCAP to v2025.06-01
1 parent 22e6261 commit cda804d

File tree

3 files changed

+49
-100
lines changed

3 files changed

+49
-100
lines changed

ModulePresentationsForCAP/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 := "ModulePresentationsForCAP",
1212
Subtitle := "Category R-pres for CAP",
13-
Version := "2024.09-02",
13+
Version := "2025.06-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

ModulePresentationsForCAP/gap/ModulePresentationsForCAP.gi

Lines changed: 16 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,15 +1093,6 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
10931093

10941094
N := UnderlyingMatrix( Range( morphism_1 ) );
10951095

1096-
# NrColumns( N ) = 0 implies coker(N)=0 and s = 0 implies coker(P)=0, hence morphism_1 is zero, and the zero morphism can always be lifted.
1097-
if NrColumns( N ) = 0 or s = 0 then
1098-
return ZeroMorphism( Source( morphism_1 ), Source( morphism_2 ) );
1099-
fi;
1100-
1101-
# if NrColumns(M)=0 then M is zero, hence lift exists iff morphism_1 is zero.
1102-
if NrColumns( M ) = 0 and IsZeroForMorphisms( morphism_1 ) then
1103-
return ZeroMorphism( Source( morphism_1 ), Source( morphism_2 ) );
1104-
fi;
11051096
A := UnderlyingMatrix( morphism_1 );
11061097

11071098
B := UnderlyingMatrix( morphism_2 );
@@ -1124,15 +1115,7 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
11241115

11251116
mat := UnionOfRows( mat1, mat2 );
11261117

1127-
if NrColumns( A ) <= 1 then
1128-
1129-
vec_A := A;
1130-
1131-
else
1132-
1133-
vec_A := UnionOfRows( List( [ 1 .. NrColumns( A ) ], i-> CertainColumns( A, [ i ] ) ) );
1134-
1135-
fi;
1118+
vec_A := ConvertMatrixToColumn( A );
11361119

11371120
vec_zero := HomalgZeroMatrix( NrRows( P ) * NrColumns( M ), NrColumns( vec_A ), homalg_ring );
11381121

@@ -1155,11 +1138,7 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
11551138

11561139
sol := CallFuncList( LeftDivide, lift_via_compiled_linear_system_func( morphism_1, morphism_2 ) );
11571140

1158-
if v <= 1 then
1159-
XX := CertainRows( sol, [ 1.. s ] );
1160-
else
1161-
XX := UnionOfColumns( List( [ 1 .. v ], i-> CertainRows( sol, [ (i-1)*s+1.. i*s ] ) ) );
1162-
fi;
1141+
XX := ConvertColumnToMatrix( CertainRows( sol, [ 1 .. s * v ] ), s, v );
11631142

11641143
return PresentationMorphism( cat, Source( morphism_1 ), XX, Source( morphism_2 ) );
11651144

@@ -1200,16 +1179,6 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
12001179

12011180
N := UnderlyingMatrix( Source( morphism_1 ) );
12021181

1203-
# NrColumns( N ) = 0 implies coker(N)=0 and s = 0 implies coker(I)=0, hence morphism_2 is zero, and the zero morphism can always be colifted.
1204-
if NrColumns( N ) = 0 or s = 0 then
1205-
return ZeroMorphism( Range( morphism_1 ), Range( morphism_2 ) );
1206-
fi;
1207-
1208-
# if NrColumns(M)=0 then M is zero, hence colift exists iff morphism_2 is zero.
1209-
if NrColumns( M ) = 0 and IsZeroForMorphisms( morphism_2 ) then
1210-
return ZeroMorphism( Range( morphism_1 ), Range( morphism_2 ) );
1211-
fi;
1212-
12131182
B := UnderlyingMatrix( morphism_1 );
12141183

12151184
A := UnderlyingMatrix( morphism_2 );
@@ -1226,12 +1195,8 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
12261195

12271196
A_over_zero := UnionOfRows( A, zero_mat );
12281197

1229-
if NrColumns( A ) <= 1 then
1230-
vec := A_over_zero;
1231-
else
1232-
vec := UnionOfRows( List( [ 1 .. NrColumns( A ) ], i-> CertainColumns( A_over_zero, [ i ] ) ) );
1233-
fi;
1234-
1198+
vec := ConvertMatrixToColumn( A_over_zero );
1199+
12351200
return [ mat, vec ];
12361201

12371202
end;
@@ -1249,15 +1214,7 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_LEFT,
12491214

12501215
sol := CallFuncList( LeftDivide, colift_via_compiled_linear_system_func( morphism_1, morphism_2 ) );
12511216

1252-
v := NrColumns( M );
1253-
1254-
s := NrColumns( I );
1255-
1256-
if s <= 1 then
1257-
XX := CertainRows( sol, [ 1.. v ] );
1258-
else
1259-
XX := UnionOfColumns( List( [ 1 .. s ], i-> CertainRows( sol, [ (i-1)*v+1.. i*v ] ) ) );
1260-
fi;
1217+
XX := ConvertColumnToMatrix( CertainRows( sol, [ 1 .. v * s ] ), v, s );
12611218

12621219
return PresentationMorphism( cat, Range( morphism_1 ), XX, Range( morphism_2 ) );
12631220

@@ -1314,14 +1271,6 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
13141271

13151272
Nt := TransposedMatrix( UnderlyingMatrix( Range( morphism_1 ) ) );
13161273

1317-
if NrRows( Nt ) = 0 or s = 0 then
1318-
return ZeroMorphism( Source( morphism_1 ), Source( morphism_2 ) );
1319-
fi;
1320-
1321-
if NrRows( Mt ) = 0 and IsZeroForMorphisms( morphism_1 ) then
1322-
return ZeroMorphism( Source( morphism_1 ), Source( morphism_2 ) );
1323-
fi;
1324-
13251274
At := TransposedMatrix( UnderlyingMatrix( morphism_1 ) );
13261275

13271276
Bt := TransposedMatrix( UnderlyingMatrix( morphism_2 ) );
@@ -1344,15 +1293,7 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
13441293

13451294
mat := UnionOfRows( mat1, mat2 );
13461295

1347-
if NrColumns( At ) <= 1 then
1348-
1349-
vec_A := At;
1350-
1351-
else
1352-
1353-
vec_A := UnionOfRows( List( [ 1 .. NrColumns( At ) ], i-> CertainColumns( At, [ i ] ) ) );
1354-
1355-
fi;
1296+
vec_A := ConvertMatrixToColumn( At );
13561297

13571298
vec_zero := HomalgZeroMatrix( NrRows( Pt ) * NrColumns( Mt ), NrColumns( vec_A ), homalg_ring );
13581299

@@ -1363,7 +1304,7 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
13631304
end;
13641305

13651306
AddLift( category, function( cat, morphism_1, morphism_2 )
1366-
local Pt, Mt, v, s, sol, XX;
1307+
local Pt, Mt, v, s, sol, XX_tr;
13671308

13681309
Pt := TransposedMatrix( UnderlyingMatrix( Source( morphism_1 ) ) );
13691310
Mt := TransposedMatrix( UnderlyingMatrix( Source( morphism_2 ) ) );
@@ -1374,13 +1315,9 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
13741315

13751316
sol := CallFuncList( LeftDivide, lift_via_compiled_linear_system_func( morphism_1, morphism_2 ) );
13761317

1377-
if v <= 1 then
1378-
XX := TransposedMatrix( CertainRows( sol, [ 1.. s ] ) );
1379-
else
1380-
XX := TransposedMatrix( UnionOfColumns( List( [ 1 .. v ], i-> CertainRows( sol, [ (i-1)*s+1.. i*s ] ) ) ) );
1381-
fi;
1318+
XX_tr := ConvertColumnToMatrix( CertainRows( sol, [ 1 .. s * v ] ), s, v );
13821319

1383-
return PresentationMorphism( cat, Source( morphism_1 ), XX, Source( morphism_2 ) );
1320+
return PresentationMorphism( cat, Source( morphism_1 ), TransposedMatrix( XX_tr ), Source( morphism_2 ) );
13841321

13851322
end );
13861323

@@ -1398,19 +1335,11 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
13981335
Mt := TransposedMatrix( UnderlyingMatrix( Range( morphism_1 ) ) );
13991336

14001337
v := NrColumns( Mt );
1401-
1338+
14021339
s := NrColumns( It );
1403-
1404-
Nt := TransposedMatrix( UnderlyingMatrix( Source( morphism_1 ) ) );
14051340

1406-
if NrRows( Nt ) = 0 or s = 0 then
1407-
return ZeroMorphism( Range( morphism_1 ), Range( morphism_2 ) );
1408-
fi;
1341+
Nt := TransposedMatrix( UnderlyingMatrix( Source( morphism_1 ) ) );
14091342

1410-
if NrRows( Mt ) = 0 and IsZeroForMorphisms( morphism_2 ) then
1411-
return ZeroMorphism( Range( morphism_1 ), Range( morphism_2 ) );
1412-
fi;
1413-
14141343
Bt := TransposedMatrix( UnderlyingMatrix( morphism_1 ) );
14151344

14161345
At := TransposedMatrix( UnderlyingMatrix( morphism_2 ) );
@@ -1427,18 +1356,14 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
14271356

14281357
A_over_zero := UnionOfRows( At, zero_mat );
14291358

1430-
if NrColumns( At ) <= 1 then
1431-
vec := A_over_zero;
1432-
else
1433-
vec := UnionOfRows( List( [ 1 .. NrColumns( At ) ], i-> CertainColumns( A_over_zero, [ i ] ) ) );
1434-
fi;
1435-
1359+
vec := ConvertMatrixToColumn( A_over_zero );
1360+
14361361
return [ mat, vec ];
14371362

14381363
end;
14391364

14401365
AddColift( category, function( cat, morphism_1, morphism_2 )
1441-
local It, Mt, v, s, sol, XX;
1366+
local It, Mt, v, s, sol, XX_tr;
14421367

14431368
It := TransposedMatrix( UnderlyingMatrix( Range( morphism_2 ) ) );
14441369

@@ -1450,17 +1375,9 @@ InstallGlobalFunction( ADD_LIFT_AND_COLIFT_RIGHT,
14501375

14511376
sol := CallFuncList( LeftDivide, colift_via_compiled_linear_system_func( morphism_1, morphism_2 ) );
14521377

1453-
v := NrColumns( Mt );
1454-
1455-
s := NrColumns( It );
1456-
1457-
if s <= 1 then
1458-
XX := TransposedMatrix( CertainRows( sol, [ 1.. v ] ) );
1459-
else
1460-
XX := TransposedMatrix( UnionOfColumns( List( [ 1 .. s ], i-> CertainRows( sol, [ (i-1)*v+1.. i*v ] ) ) ) );
1461-
fi;
1378+
XX_tr := ConvertColumnToMatrix( CertainRows( sol, [ 1 .. v * s ] ), v, s );
14621379

1463-
return PresentationMorphism( cat, Range( morphism_1 ), XX, Range( morphism_2 ) );
1380+
return PresentationMorphism( cat, Range( morphism_1 ), TransposedMatrix( XX_tr ), Range( morphism_2 ) );
14641381

14651382
end, 1000 );
14661383

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
gap> START_TEST( "Lift/Colift" );
2+
3+
gap> LoadPackage( "ModulePresentationsForCAP", false );
4+
true
5+
6+
gap> LoadPackage( "RingsForHomalg", false );
7+
true
8+
9+
gap> Qx := HomalgFieldOfRationalsInSingular() * "x";;
10+
gap> Qx_lpres := LeftPresentations( Qx );;
11+
gap> M_mat := HomalgMatrix( "[ [ 31*x^2, 34*x^2+11*x+32, 0, 0, 42*x ], [ 0, 0, 0, 0, 0 ] ]", 2, 5, Qx );;
12+
gap> M := AsLeftPresentation( M_mat );;
13+
gap> N_mat := HomalgMatrix( "[ [ 0, 0, 0, 0, 128954616*x^3+941617341*x^2+907117596*x+56921403, 39256140*x^3+41218947*x^2, 72623859*x^2+69844593*x+907117596, 70661052, 37293333*x^3+25516491*x, 98140350*x^3+69688290*x^2+561548988*x ], [ 0, 39*x, 38*x^3, 18*x^3+38*x^2, 0, 0, 48*x^3+37*x, 0, 0, 8*x^2 ], [ 0, 0, 0, 0, -580852608*x^3-1254907101*x^2-827402436*x-141045009, -97272420*x^3-102136041*x^2, -179953977*x^2-447450297*x-827402436, -175090356, -92408799*x^3-63227073*x, -243181050*x^3-342536124*x^2-512201508*x ] ]", 3, 10, Qx );;
14+
gap> N := AsLeftPresentation( N_mat );;
15+
gap> P_mat := HomalgMatrix( "[ [ 0, 0, 714*x-3696, 0 ] ]", 1, 4, Qx );;
16+
gap> P := AsLeftPresentation( P_mat );;
17+
gap> f_mat := HomalgMatrix( "[ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 166751424*x^5+94916052*x^4-127178772*x^3-42880992*x^2+13268892*x, 69479760*x^5+82104708*x^4+9608508*x^3, 128537556*x^4+75987072*x^3+7778316*x^2-143626644*x, 125063568*x^2+16471728*x, 66005772*x^5+8693412*x^4+45161844*x^3+5948124*x^2, 173699400*x^5+106253112*x^4+10981152*x^3-88911732*x^2 ], [ 1450*x^4+1161*x^3+162*x^2, 1400*x^3+252*x^2, 0, 0, 450*x+81, 0, 0, 500*x^4+90*x^3+800*x^2+144*x, 2350*x^3+2523*x^2+1028*x+117, 0 ], [ 0, 0, 0, 0, 71464896*x^5+40678308*x^4-54505188*x^3-18377568*x^2+5686668*x, 29777040*x^5+35187732*x^4+4117932*x^3+420*x^2+555*x+240, 55087524*x^4+32566428*x^3+3333564*x^2-61554276*x, 53598672*x^2+7059312*x, 28288188*x^5+3725748*x^4+19355076*x^3+2549196*x^2, 74442600*x^5+45537048*x^4+4706358*x^3-38105028*x^2+720*x+480 ], [ 0, 0, 0, 0, -3970272000*x^4-2259906000*x^3+3028066000*x^2+1020976000*x-315926000, -1654280000*x^4-1954874000*x^3-228774000*x^2, -3060418000*x^3-1809216000*x^2-185198000*x+3419682000, -2977704000*x-392184000, -1571566000*x^4-206986000*x^3-1075282000*x^2-141622000*x, -4135700000*x^4-2529836000*x^3-261456000*x^2+2116946000*x ] ]", 5, 10, Qx );;
18+
gap> f := PresentationMorphism( M, f_mat, N );;
19+
gap> g_mat := HomalgMatrix( "[ [ 29*x^3+18*x^2, 28*x^2, 0, 0, 9, 0, 0, 10*x^3+16*x, 47*x^2+42*x+13, 0 ], [ 0, 0, 0, 0, 0, 28*x^2+37*x+16, 36*x^3, 0, 0, 10*x^3+48*x+32 ], [ 0, 0, 0, 0, 1985136*x^4+1129953*x^3-1514033*x^2-510488*x+157963, 827140*x^4+977437*x^3+114387*x^2, 1530209*x^3+904608*x^2+92599*x-1709841, 1488852*x+196092, 785783*x^4+103493*x^3+537641*x^2+70811*x, 2067850*x^4+1264918*x^3+130728*x^2-1058473*x ], [ 43*x, 0, 0, 0, 5*x, 0, 0, 0, 14*x^3, 34 ] ]", 4, 10, Qx );;
20+
gap> g := PresentationMorphism( P, g_mat, N );;
21+
gap> l := Lift( f, g );;
22+
gap> Assert( 0, PreCompose( l, Colift( l, f ) ) = f and PreCompose( l, g ) = f );
23+
gap> Qx_rpres := RightPresentations( Qx );;
24+
gap> M := AsRightPresentation( TransposedMatrix( M_mat ) );;
25+
gap> N := AsRightPresentation( TransposedMatrix( N_mat ) );;
26+
gap> P := AsRightPresentation( TransposedMatrix( P_mat ) );;
27+
gap> f := PresentationMorphism( M, TransposedMatrix( f_mat ), N );;
28+
gap> g := PresentationMorphism( P, TransposedMatrix( g_mat ), N );;
29+
gap> l := Lift( f, g );;
30+
gap> Assert( 0, PreCompose( l, Colift( l, f ) ) = f and PreCompose( l, g ) = f );;
31+
32+
gap> STOP_TEST( "Lift/Colift" );

0 commit comments

Comments
 (0)