Skip to content

Improve conjugation test for subgroups with different orders#6267

Merged
ThomasBreuer merged 1 commit intogap-system:masterfrom
limakzi:6266-improve-isconjugate
Mar 24, 2026
Merged

Improve conjugation test for subgroups with different orders#6267
ThomasBreuer merged 1 commit intogap-system:masterfrom
limakzi:6266-improve-isconjugate

Conversation

@limakzi
Copy link
Member

@limakzi limakzi commented Mar 12, 2026

Conjugate subgroups have the same order.
When the sizes of both subgroups are already known (via HasSize), IsConjugate and RepresentativeActionOp now return immediately if the sizes differ, avoiding expensive conjugacy computations.

Fixes #6266

Copilot AI review requested due to automatic review settings March 12, 2026 22:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds early-exit checks in IsConjugate and RepresentativeActionOp to immediately return when two subgroups have different known orders, avoiding expensive conjugacy computations.

Changes:

  • Add size-comparison short-circuit in IsConjugate for groups (lib/grp.gi)
  • Add size-comparison short-circuit in RepresentativeActionOp for permutation groups (lib/oprtperm.gi)
  • Add a test case for the new behavior (tst/testinstall/ConjNatSym.tst)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
lib/grp.gi Early return false when subgroup sizes are known and differ
lib/oprtperm.gi Early return fail when subgroup sizes are known and differ
tst/testinstall/ConjNatSym.tst Test case for non-conjugate subgroups with different orders

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

InstallMethod(IsConjugate,"subgroups",IsFamFamFam,[IsGroup, IsGroup,IsGroup],
function(g,x,y)
# conjugate subgroups must have the same order
if HasSize(x) and HasSize(y) and Size(x) <> Size(y) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there are other properties and attributes (isomorphism invariants) that would be worthwhile to check? Like IsAbelian, IsSolvableGroup, IsPerfectGroup, NrConjugacyClasses and a gazillion more. With help of Tester and Getter one could easily handle them uniformly with a loop. But is it worth it? Hm.

I do think Size is worth it for sure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. As you noted there are gazillion isomorphism invariants.
Some are difficult to compute and the difficulty differs between groups.
Proposal:

InstallGlobalFunction( KnownIsomorphismInvariantsMatch,
function( G, H )
    local inv;
    for inv in [ Size, AbelianInvariants, DerivedLength,
                 NilpotencyClassOfGroup, Exponent, HirschLength,
                 IsAbelian, IsNilpotentGroup, IsSolvableGroup,
                 IsPerfectGroup, IsSimpleGroup, IsSporadicSimpleGroup ] do
        if Tester(inv)(G) and Tester(inv)(H) and inv(G) <> inv(H) then
            return false;
        fi;
    od;
    return true;
end );

Then

if not KnownIsomorphismInvariantsMatch(d, e) then
  return fail;
fi;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This IsConjugate method calls RepresentativeAction if the shortcut for normal subgroups does not strike. Thus I think it is sufficient to add new tests only in RepresentativeActionOp methods in question.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! The only thing we miss is catalog of checks.
How do you like the proposal I put above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed this with @ThomasBreuer yesterday, and I think our rough agreement was that we should merge this here as-is, and only implement further invariants if either someone has a concrete need (= has use cases were they matter), or someone spends time to carefully test the code with and without the invariants, in various situations -- because experience tells that "let's just check this catalogue of invariants, they are all cheap so this is fine" is a dangerous trap, because testing a dozen "cheap" invariants with non-trivial orchestration code (= more overhead) quickly turns into "not so cheap after all".

@ThomasBreuer if you agree, please merge; otherwise, add another comment

@limakzi limakzi force-pushed the 6266-improve-isconjugate branch 2 times, most recently from c9f0149 to f31fa88 Compare March 23, 2026 21:44
@limakzi limakzi force-pushed the 6266-improve-isconjugate branch from f31fa88 to 5ce0dc2 Compare March 23, 2026 21:45
@ThomasBreuer ThomasBreuer merged commit 5b88db1 into gap-system:master Mar 24, 2026
32 checks passed
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.

IsConjugate does not try cheap invariants that may yield a false result

5 participants