Skip to content

Commit 9698962

Browse files
authored
Fix FieldOfMatrixGroup calls, analogous to the GAP library (#82)
1 parent c54faa1 commit 9698962

File tree

2 files changed

+80
-18
lines changed

2 files changed

+80
-18
lines changed

lib/classic.gi

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,39 @@ BindGlobal( "_IsEqualModScalars",
4343
return IsZero( mat2 );
4444
end );
4545

46+
# The following helper function provides compatibility
47+
# with older GAP versions.
48+
# Before gap-system/gap/pull/6203, 'FieldOfMatrixGroup( G )' was interpreted
49+
# as the field of definition of the invariant forms stored in 'G'.
50+
# This was not always correct, hence we decided to add a component
51+
# 'baseDomain' to the records that describe the invariant forms created with
52+
# 'InvariantBilinearForm' etc.
53+
BindGlobal("Forms_FieldOfDefinition", function( form_record, G )
54+
if IsBound( form_record.baseDomain ) then
55+
return form_record.baseDomain;
56+
else
57+
return FieldOfMatrixGroup( G );
58+
fi;
59+
end );
60+
4661
BindGlobal("Forms_OrthogonalGroup",
4762
function( g, form )
4863
local stored, gf, d, wanted, mat1, mat2, mat, matinv, gens, gg;
4964

50-
stored:= InvariantQuadraticForm( g ).matrix;
65+
stored:= InvariantQuadraticForm( g );
66+
gf:= Forms_FieldOfDefinition( stored, g );
67+
stored:= stored.matrix;
68+
69+
# Check that 'form' lives over the intended field.
70+
if not IsSubset( gf, form!.basefield ) then
71+
Error( "the defining field of <form> does not fit to <gf>" );
72+
fi;
5173

5274
# If the prescribed form fits then just return.
5375
if stored = form!.matrix then
5476
return g;
5577
fi;
5678

57-
gf:= FieldOfMatrixGroup( g );
5879
d:= DimensionOfMatrixGroup( g );
5980

6081
# Compute a base change matrix.
@@ -80,7 +101,8 @@ BindGlobal("Forms_OrthogonalGroup",
80101
SetName( gg, Name( g ) );
81102
fi;
82103

83-
SetInvariantQuadraticForm( gg, rec( matrix:= form!.matrix ) );
104+
SetInvariantQuadraticForm( gg, rec( matrix:= form!.matrix,
105+
baseDomain:= gf ) );
84106
if HasIsFullSubgroupGLorSLRespectingQuadraticForm( g ) then
85107
SetIsFullSubgroupGLorSLRespectingQuadraticForm( gg,
86108
IsFullSubgroupGLorSLRespectingQuadraticForm( g ) );
@@ -138,7 +160,7 @@ InstallMethod( GeneralOrthogonalGroupCons,
138160
{ filt, G } -> GeneralOrthogonalGroupCons( filt,
139161
QuadraticFormByMatrix(
140162
InvariantQuadraticForm( G ).matrix,
141-
FieldOfMatrixGroup( G ) ) ) );
163+
Forms_FieldOfDefinition( InvariantQuadraticForm( G ), G ) ) ) );
142164

143165
InstallMethod( GeneralOrthogonalGroupCons,
144166
"matrix group for form",
@@ -278,7 +300,7 @@ InstallMethod( SpecialOrthogonalGroupCons,
278300
{ filt, G } -> SpecialOrthogonalGroupCons( filt,
279301
QuadraticFormByMatrix(
280302
InvariantQuadraticForm( G ).matrix,
281-
FieldOfMatrixGroup( G ) ) ) );
303+
Forms_FieldOfDefinition( InvariantQuadraticForm( G ), G ) ) ) );
282304

283305
InstallMethod( SpecialOrthogonalGroupCons,
284306
"matrix group for form",
@@ -455,7 +477,7 @@ InstallMethod( OmegaCons,
455477
{ filt, G } -> OmegaCons( filt,
456478
QuadraticFormByMatrix(
457479
InvariantQuadraticForm( G ).matrix,
458-
FieldOfMatrixGroup( G ) ) ) );
480+
Forms_FieldOfDefinition( InvariantQuadraticForm( G ), G ) ) ) );
459481

460482
InstallMethod( OmegaCons,
461483
"matrix group for form",
@@ -563,7 +585,7 @@ InstallMethod( GeneralUnitaryGroupCons,
563585
{ filt, G } -> GeneralUnitaryGroupCons( filt,
564586
HermitianFormByMatrix(
565587
InvariantSesquilinearForm( G ).matrix,
566-
FieldOfMatrixGroup( G ) ) ) );
588+
Forms_FieldOfDefinition( InvariantSesquilinearForm( G ), G ) ) ) );
567589

568590
InstallMethod( GeneralUnitaryGroupCons,
569591
"matrix group for form",
@@ -619,20 +641,26 @@ InstallMethod( GeneralUnitaryGroupCons,
619641
IsPosInt,
620642
IsHermitianForm ],
621643
function( filt, d, q, form )
622-
local g, stored, wanted, mat1, mat2, mat, matinv, gens, gg;
644+
local g, stored, F, wanted, mat1, mat2, mat, matinv, gens, gg;
623645

624646
# Create the default generators and form.
625647
g:= GeneralUnitaryGroupCons( filt, d, q );
626648
stored:= InvariantSesquilinearForm( g ).matrix;
627649

650+
# Check that 'form' lives over the intended field.
651+
F:= GF(q^2);
652+
if not IsSubset( F, form!.basefield ) then
653+
Error( "the defining field of <form> does not fit to <q>" );
654+
fi;
655+
628656
# If the prescribed form fits then just return.
629657
if stored = form!.matrix then
630658
return g;
631659
fi;
632660

633661
# Compute a base change matrix.
634662
# (Check that the canonical forms are equal.)
635-
wanted:= HermitianFormByMatrix( stored, GF(q^2) );
663+
wanted:= HermitianFormByMatrix( stored, F );
636664
mat1:= BaseChangeToCanonical( form );
637665
mat2:= BaseChangeToCanonical( wanted );
638666
if mat1 * form!.matrix * TransposedFrobeniusMat( mat1, q ) <>
@@ -652,7 +680,9 @@ InstallMethod( GeneralUnitaryGroupCons,
652680
SetName( gg, Name( g ) );
653681
fi;
654682

655-
SetInvariantSesquilinearForm( gg, rec( matrix:= form!.matrix ) );
683+
SetInvariantSesquilinearForm( gg, rec( matrix:= form!.matrix,
684+
baseDomain:= F ) );
685+
656686
if HasIsFullSubgroupGLorSLRespectingSesquilinearForm( g ) then
657687
SetIsFullSubgroupGLorSLRespectingSesquilinearForm( gg,
658688
IsFullSubgroupGLorSLRespectingSesquilinearForm( g ) );
@@ -708,7 +738,7 @@ InstallMethod( SpecialUnitaryGroupCons,
708738
{ filt, G } -> SpecialUnitaryGroupCons( filt,
709739
HermitianFormByMatrix(
710740
InvariantSesquilinearForm( G ).matrix,
711-
FieldOfMatrixGroup( G ) ) ) );
741+
Forms_FieldOfDefinition( InvariantSesquilinearForm( G ), G ) ) ) );
712742

713743
InstallMethod( SpecialUnitaryGroupCons,
714744
"matrix group for form",
@@ -748,7 +778,7 @@ InstallMethod( SpecialUnitaryGroupCons,
748778
IsPosInt,
749779
IsHermitianForm ],
750780
function( filt, d, q, form )
751-
local g, stored, wanted, mat1, mat2, mat, matinv, gens, gg;
781+
local g, stored, F, wanted, mat1, mat2, mat, matinv, gens, gg;
752782

753783
# Create the default generators and form.
754784
g:= SpecialUnitaryGroupCons( filt, d, q );
@@ -759,9 +789,15 @@ InstallMethod( SpecialUnitaryGroupCons,
759789
return g;
760790
fi;
761791

792+
# Check that 'form' lives over the intended field.
793+
F:= GF(q^2);
794+
if not IsSubset( F, form!.basefield ) then
795+
Error( "the defining field of <form> does not fit to <q>" );
796+
fi;
797+
762798
# Compute a base change matrix.
763799
# (Check that the canonical forms are equal.)
764-
wanted:= HermitianFormByMatrix( stored, GF(q^2) );
800+
wanted:= HermitianFormByMatrix( stored, F );
765801
mat1:= BaseChangeToCanonical( form );
766802
mat2:= BaseChangeToCanonical( wanted );
767803
if mat1 * form!.matrix * TransposedFrobeniusMat( mat1, q ) <>
@@ -781,7 +817,9 @@ InstallMethod( SpecialUnitaryGroupCons,
781817
SetName( gg, Name( g ) );
782818
fi;
783819

784-
SetInvariantSesquilinearForm( gg, rec( matrix:= form!.matrix ) );
820+
SetInvariantSesquilinearForm( gg, rec( matrix:= form!.matrix,
821+
baseDomain:= F ) );
822+
785823
if HasIsFullSubgroupGLorSLRespectingSesquilinearForm( g ) then
786824
SetIsFullSubgroupGLorSLRespectingSesquilinearForm( gg,
787825
IsFullSubgroupGLorSLRespectingSesquilinearForm( g ) );
@@ -830,7 +868,7 @@ InstallMethod( SymplecticGroupCons,
830868
{ filt, G } -> SymplecticGroupCons( filt,
831869
BilinearFormByMatrix(
832870
InvariantBilinearForm( G ).matrix,
833-
FieldOfMatrixGroup( G ) ) ) );
871+
Forms_FieldOfDefinition( InvariantBilinearForm( G ), G ) ) ) );
834872

835873
InstallMethod( SymplecticGroupCons,
836874
"matrix group for form",
@@ -870,7 +908,7 @@ InstallMethod( SymplecticGroupCons,
870908
IsPosInt,
871909
IsBilinearForm ],
872910
function( filt, d, q, form )
873-
local g, stored, wanted, mat1, mat2, mat, matinv, gens, gg;
911+
local g, stored, F, wanted, mat1, mat2, mat, matinv, gens, gg;
874912

875913
# Create the default generators and form.
876914
g:= SymplecticGroupCons( filt, d, q );
@@ -881,9 +919,15 @@ InstallMethod( SymplecticGroupCons,
881919
return g;
882920
fi;
883921

922+
# Check that 'form' lives over the intended field.
923+
F:= GF(q);
924+
if not IsSubset( F, form!.basefield ) then
925+
Error( "the defining field of <form> does not fit to <q>" );
926+
fi;
927+
884928
# Compute a base change matrix.
885929
# (Check that the canonical forms are equal.)
886-
wanted:= BilinearFormByMatrix( stored, GF(q) );
930+
wanted:= BilinearFormByMatrix( stored, F );
887931
mat1:= BaseChangeToCanonical( form );
888932
mat2:= BaseChangeToCanonical( wanted );
889933
if mat1 * form!.matrix * TransposedMat( mat1 ) <>
@@ -903,7 +947,8 @@ InstallMethod( SymplecticGroupCons,
903947
SetName( gg, Name( g ) );
904948
fi;
905949

906-
SetInvariantBilinearForm( gg, rec( matrix:= form!.matrix ) );
950+
SetInvariantBilinearForm( gg, rec( matrix:= form!.matrix,
951+
baseDomain:= F ) );
907952
if HasIsFullSubgroupGLorSLRespectingBilinearForm( g ) then
908953
SetIsFullSubgroupGLorSLRespectingBilinearForm( gg,
909954
IsFullSubgroupGLorSLRespectingBilinearForm( g ) );

tst/adv/classic.tst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,23 @@ gap> g:= GO( 3, 257, mat );;
201201
gap> InvariantQuadraticForm( g ).matrix = mat;
202202
true
203203

204+
# Test inconsistent fields of definition.
205+
gap> g:= GeneralOrthogonalGroup( 5, GF(3) );;
206+
gap> mat:= InvariantQuadraticForm( g ).matrix;;
207+
gap> form:= QuadraticFormByMatrix( mat, GF(9) );;
208+
gap> GeneralOrthogonalGroup( 5, GF(3), form );;
209+
Error, the defining field of <form> does not fit to <gf>
210+
gap> g:= GeneralUnitaryGroup( 4, 2 );;
211+
gap> mat:= InvariantSesquilinearForm( g ).matrix;;
212+
gap> form:= HermitianFormByMatrix( mat, GF(16) );;
213+
gap> GeneralUnitaryGroup( 4, 2, form );
214+
Error, the defining field of <form> does not fit to <q>
215+
gap> g:= SymplecticGroup( 4, GF(2) );;
216+
gap> mat:= InvariantBilinearForm( g ).matrix;;
217+
gap> form:= BilinearFormByMatrix( mat, GF(4) );;
218+
gap> SymplecticGroup( 4, GF(2), form );
219+
Error, the defining field of <form> does not fit to <q>
220+
204221
# Increase the code coverage.
205222
gap> mat:= IdentityMat( 3, GF(5) );;
206223
gap> _IsEqualModScalars( mat, Z(5) * mat );

0 commit comments

Comments
 (0)