Skip to content

Hook up the new constructive recognition branches, and provide rewriting methods for the classical groups - #559

Draft
fingolfin wants to merge 7 commits into
mh-ai/paper-ofrom
mh-ai/paper-rewrite
Draft

fingolfin wants to merge 7 commits into
mh-ai/paper-ofrom
mh-ai/paper-rewrite

Conversation

@fingolfin

Copy link
Copy Markdown
Member

The original plan was to base this on Daniel's BruhatDecomposition code. But the resulting SLPs are waaaay too long, this would just not be useable in practice and far from competitive with Magma, too.

Assisted-by: Generative AI

@fingolfin
fingolfin added this pull request to stack #560 November 15, 2026 10:16
@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.86822% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.63%. Comparing base (da12f40) to head (e99fc85).

Files with missing lines Patch % Lines
gap/projective/classicalnatural.gi 95.45% 9 Missing ⚠️
gap/projective/constructive_recognition/Rewrite.gi 99.30% 1 Missing ⚠️
gap/projective/constructive_recognition/SU/main.gi 85.71% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           mh-ai/paper-o     #559      +/-   ##
=================================================
- Coverage          88.67%   87.63%   -1.04%     
=================================================
  Files                 61       63       +2     
  Lines              20931    21331     +400     
=================================================
+ Hits               18561    18694     +133     
- Misses              2370     2637     +267     
Files with missing lines Coverage Δ
gap/projective/constructive_recognition/GoingUp.gi 97.20% <100.00%> (+0.68%) ⬆️
.../projective/constructive_recognition/SL/GoingUp.gi 98.77% <ø> (+0.40%) ⬆️
.../projective/constructive_recognition/SL/Rewrite.gi 100.00% <100.00%> (ø)
gap/projective/constructive_recognition/SL/main.gi 100.00% <100.00%> (ø)
...projective/constructive_recognition/utils/utils.gi 88.88% <100.00%> (+15.55%) ⬆️
gap/projective/constructive_recognition/Rewrite.gi 99.30% <99.30%> (ø)
gap/projective/constructive_recognition/SU/main.gi 90.00% <85.71%> (+2.00%) ⬆️
gap/projective/classicalnatural.gi 70.45% <95.45%> (+3.45%) ⬆️

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fingolfin
fingolfin removed this pull request from stack #560 November 15, 2026 23:13
@fingolfin
fingolfin added this pull request to stack #542 November 15, 2026 23:13
The PSLd leaf of ClassicalNatural wrote elements as SLPs in the
generators of RECOG.MakeSL_StdGens, to which FindStdGens_SL translated
its result. Its row reduction uses elementary matrices E(i, j, .) for
all i and j and builds each one anew from the cycles a, b and the field
basis, so its SLPs are long, and evaluating them in a parent node is
slow.

RECOG.SL_Rewrite works with E(1, j, .) and E(j, 1, .) only, whose words
it caches: it clears row and column 1, then conjugates by a cycle of all
basis lines to bring the next index to position 1, as Magma's
ClassicalRewrite does after Costi's thesis. Since the cycle is monomial
and row 1 is cleared by one rank-1 update, each index costs O(d^2) field
operations. The leaf now uses the standard generators of
RECOG.ClassicalStandardGenerators, so FindStdGens_SL drops its
translation, and RECOG.ExpressInStd_SL and
RECOG.SL_MakeSLStdGensFromStandard are removed.

Setup, SL(100,3):

    gap> Time := function(f) local t; t := Runtime(); f(); return Runtime() - t; end;; slps := [];;
    gap> Reset(GlobalMersenneTwister, 1);; Reset(GlobalRandomSource, 1);;
    gap> G := SL(100, 3)^PseudoRandom(GL(100, 3));; xs := List([1 .. 5], i -> PseudoRandom(G));;
    gap> leaf := ImageRecogNode(RecognizeGroup(G));; leaf!.comment;
    "PSLd"

Before:

    gap> Time(function() slps := List(xs, x -> SLPforElement(leaf, x)); end);
    467
    gap> Time(function() List(slps, s -> ResultOfStraightLineProgram(s, NiceGens(leaf))); end);
    93592

After:

    gap> Time(function() slps := List(xs, x -> SLPforElement(leaf, x)); end);
    171
    gap> Time(function() List(slps, s -> ResultOfStraightLineProgram(s, NiceGens(leaf))); end);
    8874

Setup, SL(50,81):

    gap> Reset(GlobalMersenneTwister, 1);; Reset(GlobalRandomSource, 1);;
    gap> G := SL(50, 81)^PseudoRandom(GL(50, 81));; xs := List([1 .. 3], i -> PseudoRandom(G));;
    gap> leaf := ImageRecogNode(RecognizeGroup(G));; leaf!.comment;
    "PSLd"

Before:

    gap> Time(function() slps := List(xs, x -> SLPforElement(leaf, x)); end);
    280
    gap> Time(function() List(slps, s -> ResultOfStraightLineProgram(s, NiceGens(leaf))); end);
    20876

After:

    gap> Time(function() slps := List(xs, x -> SLPforElement(leaf, x)); end);
    64
    gap> Time(function() List(slps, s -> ResultOfStraightLineProgram(s, NiceGens(leaf))); end);
    2639

Assisted-by: Generative AI
Each step of RECOG.SL_Rewrite conjugated by cyc^-1, and inverting the
word anew added a node to the SLP every time.

Assisted-by: Generative AI
ClassicalNatural only handled groups containing SL. Symplectic groups
fell through to a stabiliser chain on the (q^d-1)/(q-1) projective
points.

If RecogniseClassical reports Sp(d,q) with q odd, ClassicalNatural now
scales the generators into Sp(d,q) by square roots of their similarity
factors, finds standard generators with RECOG.FindStdGens_Sp and makes a
PSp leaf. Its SLPforElement scales an element into Sp, picks one of y
and -y, and rewrites it with RECOG.Form_Rewrite. This is the elimination
of RECOG.SL_Rewrite for groups with a form: each step clears the images
of e_1 and f_1 with the cached root elements of the GoingUp, then
conjugates by v.

Groups whose similarity factors are not all squares, such as conformal
symplectic groups, and small cases with at most 1000 projective points
still go to the other methods.

Setup:

    gap> Time := function(f) local t; t := Runtime(); f(); return Runtime() - t; end;; ri := 0;; SetInfoLevel(InfoOrb, 0);;
    gap> Reset(GlobalMersenneTwister, 1);; Reset(GlobalRandomSource, 1);;
    gap> G := Sp(10, 3)^PseudoRandom(GL(10, 3));; xs := List([1 .. 5], i -> PseudoRandom(G));;

Before:

    gap> Time(function() ri := RecognizeGroup(G); end);
    1894
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    1

After:

    gap> Time(function() ri := RecognizeGroup(G); end);
    185
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    3

Setup:

    gap> Reset(GlobalMersenneTwister, 1);; Reset(GlobalRandomSource, 1);;
    gap> G := Sp(8, 5)^PseudoRandom(GL(8, 5));; xs := List([1 .. 5], i -> PseudoRandom(G));;

Before:

    gap> Time(function() ri := RecognizeGroup(G); end);
    7187
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    1

After:

    gap> Time(function() ri := RecognizeGroup(G); end);
    87
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    2

Assisted-by: Generative AI
ClassicalNatural made leaves only for groups containing SL or Sp.
Unitary groups fell through to a stabiliser chain on the projective
points.

If RecogniseClassical reports SU(d,q0) with d even and q0 odd,
ClassicalNatural now scales the generators into SU(d,q0), finds
standard generators with RECOG.FindStdGens_SU, which now also takes
d = 4, and makes a PSU leaf. The Sp leaf code is generalised for this:
an element is scaled by lambda with lambda^(q0+1) the inverse of its
similarity factor and lambda^d det(g) = 1, then normalised modulo the
centre of order gcd(d, q0+1). RECOG.Form_Rewrite handles SU: the torus
element y also scales the second pair, so the last step leaves a power
of delta^u there, which is removed at the end.

Unitary groups whose determinants scalars cannot bring to 1, such as
GU(4,5), and small cases still go to the other methods. So do most
groups with scalars outside GU on the generators: for them
RecogniseClassical usually misses the form, because
ClassicalForms_ScalarMultipleFrobenius of Forms 1.3.0 returns the
similarity factor instead of its (q0+1)-th root.

Setup:

    gap> Time := function(f) local t; t := Runtime(); f(); return Runtime() - t; end;; ri := 0;; SetInfoLevel(InfoOrb, 0);;
    gap> Reset(GlobalMersenneTwister, 1);; Reset(GlobalRandomSource, 1);;
    gap> G := SU(6, 3)^PseudoRandom(GL(6, 9));; xs := List([1 .. 5], i -> PseudoRandom(G));;

Before:

    gap> Time(function() ri := RecognizeGroup(G); end);
    1222
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    0

After:

    gap> Time(function() ri := RecognizeGroup(G); end);
    86
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    3

Setup:

    gap> Reset(GlobalMersenneTwister, 1);; Reset(GlobalRandomSource, 1);;
    gap> G := SU(4, 7)^PseudoRandom(GL(4, 49));; xs := List([1 .. 5], i -> PseudoRandom(G));;

Before:

    gap> Time(function() ri := RecognizeGroup(G); end);
    1018
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    0

After:

    gap> Time(function() ri := RecognizeGroup(G); end);
    40
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    2

Assisted-by: Generative AI
ClassicalNatural made no leaves for orthogonal groups. They fell
through to a stabiliser chain on the projective points.

If RecogniseClassical reports Omega(d,q) with q odd and d >= 8,
ClassicalNatural now scales the generators into Omega(d,q), finds
standard generators with RECOG.FindStdGens_O and makes a POmega leaf. A
generator with similarity factor mu is scaled by lambda or -lambda,
lambda^2 = 1/mu, so that it has determinant 1 and spinor norm 1. The
spinor norm is the discriminant of the Wall form (Taylor, The geometry
of the classical groups, Theorem 11.51). So SO(d,q) and GO(d,q) fall
through, unless they lie in Omega(d,q) times scalars, as SO+(10,3)
does.

RECOG.Form_Rewrite handles the orthogonal types with the root elements
of the GoingUp for the Omega+(2m) on the hyperbolic pairs. For types -
and o, whose standard generators are s, t, delta, u, v, the standard
generators of that Omega+(2m) are words in them, built from
commutators of t and its conjugates. RECOG.Form_MapToStd and
RECOG.Form_MapToF1FixingE1 clear the anisotropic part with the Siegel
transformations rho(f_1, z) and rho(e_1, z), conjugates of t. The torus
leaves a residue on the second pair, and for type - one on the
anisotropic part, which the end removes.

Setup:

    gap> Time := function(f) local t; t := Runtime(); f(); return Runtime() - t; end;; ri := 0;; SetInfoLevel(InfoOrb, 0);;
    gap> Reset(GlobalMersenneTwister, 1);; Reset(GlobalRandomSource, 1);;
    gap> G := Omega(1, 10, 3)^PseudoRandom(GL(10, 3));; xs := List([1 .. 5], i -> PseudoRandom(G));;

Before:

    gap> Time(function() ri := RecognizeGroup(G); end);
    3018
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    0

After:

    gap> Time(function() ri := RecognizeGroup(G); end);
    77
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    4

Setup:

    gap> Reset(GlobalMersenneTwister, 1);; Reset(GlobalRandomSource, 1);;
    gap> G := Omega(-1, 8, 5)^PseudoRandom(GL(8, 5));; xs := List([1 .. 5], i -> PseudoRandom(G));;

Before:

    gap> Time(function() ri := RecognizeGroup(G); end);
    1802
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    1

After:

    gap> Time(function() ri := RecognizeGroup(G); end);
    91
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    3

Setup:

    gap> Reset(GlobalMersenneTwister, 1);; Reset(GlobalRandomSource, 1);;
    gap> G := Omega(9, 3)^PseudoRandom(GL(9, 3));; xs := List([1 .. 5], i -> PseudoRandom(G));;

Before:

    gap> Time(function() ri := RecognizeGroup(G); end);
    2665
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    0

After:

    gap> Time(function() ri := RecognizeGroup(G); end);
    71
    gap> Time(function() List(xs, x -> SLPforElement(ri, x)); end);
    3

Assisted-by: Generative AI
RECOG.HasTrivialSpinorNorm took the field for its square test from the
entries of the matrix. An element of Omega over GF(9) whose entries lie
in GF(3), such as -1 on one hyperbolic pair, whose spinor norm -1 is a
square in GF(9) but not in GF(3), was rejected. It now takes a form
record and uses its field.

Assisted-by: Generative AI
SLPforElement on an Sp, SU or Omega leaf raised an error for a group
element times a scalar outside the field of the leaf, e.g. Z(9) x for
x in Omega(9,3): RECOG.ClassicalNaturalScalar then takes a root, in the
field of the leaf, of a similarity factor outside it.

Divide the element by an entry first, and return fail if it still has
entries outside the field, as an element of Omega(9,9) does.

Assisted-by: Generative AI

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant