add and integrate a SL2 in natural rep. recognition algorithm by Frank Lübeck #389
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## Include_ConstructiveRecognition_SL #389 +/- ##
=====================================================================
Coverage ? 65.52%
=====================================================================
Files ? 49
Lines ? 20671
Branches ? 0
=====================================================================
Hits ? 13545
Misses ? 7126
Partials ? 0
🚀 New features to boost your workflow:
|
7abb134 to
84ff4f1
Compare
15c6c86 to
894600f
Compare
|
I think we should just raise the minimum GAP version to 4.13. The problem with the 4.12 test failure is that the function |
| ## test function: compares ConRecogNaturalSL2 against the built-in recognition | ||
| ## note: does not work for q = 2, 3, 5 | ||
| ## Input: either a list of prime powers or the empty list | ||
| ## (then a preset list of prime powers is tested). | ||
| test_ConRecogNaturalSL2 := function(input) |
There was a problem hiding this comment.
This needs to be turned into "proper" tests.
For example it could be moved into tst/utils.g or some other tst/BLAH.g file (could even be a new one); and a .tst file (either an existing one or a new one) should invoke this helper in a suitable way to ensure some of these tests are run as part of our CI.
Feel free to ask about details.
| res_old := RECOG.RecogniseSL2NaturalOddCharUsingBSGS(G,f); | ||
| fi; | ||
| res := RECOG.ConRecogNaturalSL2(G,f); | ||
| ## compare all generators after change of basis |
There was a problem hiding this comment.
Ah so this test "only" checks that the old and new method get to the same result.
That maybe changes whether we should add these tests to the permanent tests, as the plan would be to delete RECOG.RecogniseSL2NaturalEvenChar and RECOG.RecogniseSL2NaturalOddCharUsingBSGS at some point.
Also, in the end, the "comparison" matrices can be reproduce much cheaper via
std := RECOG.MakeSL_StdGens(Characteristic(f),DegreeOverPrimeField(f),2,2);
So you could then compare res.all[i]^res.basi to those and not care about res_old at all.
eaf9760 to
3407986
Compare
| if IsEvenInt(q) then | ||
| std := RECOG.RecogniseSL2NaturalEvenChar(gm,f,false); | ||
| std := RECOG.ConRecogNaturalSL2(gm,f); | ||
| ri!.comment := "PSL2Even"; | ||
| else | ||
| std := RECOG.RecogniseSL2NaturalOddCharUsingBSGS(gm,f); | ||
| std := RECOG.ConRecogNaturalSL2(gm,f); | ||
| ri!.comment := "PSL2Odd"; | ||
| fi; |
There was a problem hiding this comment.
This could be merged together now, with ri!.comment := "PSL2";
| else | ||
| resl2 := RECOG.RecogniseSL2NaturalOddCharUsingBSGS(Group(sl2genss),f); | ||
| fi; | ||
| resl2 := RECOG.ConRecogNaturalSL2(Group(sl2genss),f); |
There was a problem hiding this comment.
For fun I did a local benchmark:
gap> q:=2;; for i in [1..1000] do RECOG.RecogniseSL2NaturalOddCharUsingBSGS(SL(2,q),GF(q)); od; time;
608
gap> q:=2;; for i in [1..1000] do RECOG.RecogniseSL2NaturalEvenChar(SL(2,q),GF(q),false); od; time;
302
Note that I run the test a 1000 times in a loop to get better "accuracy. So 302 milliseconds for 1000 runs means 0.3 milliseconds per run. Not bad. And the specialized method indeed was faster.
Now you could try to compare this to your new code.
| ## as RECOG.RecogniseSL2NaturalEvenChar and | ||
| ## RECOG.RecogniseSL2NaturalOddCharUsingBSGS. | ||
| ## G must be SL(2,q) generated by 2x2 matrices over GF(q). | ||
| RECOG.ConRecogNaturalSL2 := function(G, f) |
There was a problem hiding this comment.
I've not yet looked at the content of this function, but I did run some benchmarks and they show that this function adds quite some overhead over Frank's code:
gap> q:=13^2;; for i in [1..1000] do RECOG.RecogniseSL2NaturalOddCharUsingBSGS(SL(2,q),GF(q)); od; time;
2432
gap> q:=13^2;; for i in [1..1000] do RECOG.ConRecogNaturalSL2(SL(2,q),GF(q)); od; time;
1202
gap> q:=13^2;; for i in [1..1000] do RECOG.RecogNaturalSL2(SL(2,q),q); od; time;
814
So it's still twice faster than the old code, but 50% slower than Frank's code.
In even char however it is almost three times slower than the old code, yet Frank's code is three times faster than the old code.
gap> q:=8;; for i in [1..1000] do RECOG.RecogniseSL2NaturalEvenChar(SL(2,q),GF(q),false); od; time;
1404
gap> q:=8;; for i in [1..1000] do RECOG.ConRecogNaturalSL2(SL(2,q),GF(q)); od; time;
4116
gap> q:=8;; for i in [1..1000] do RECOG.RecogNaturalSL2(SL(2,q),q); od; time;
513
| true_u1 := [[Z(q)^0,0*Z(q)],[Z(q)^0,Z(q)^0]]; | ||
| true_u2 := [[Z(q)^0,Z(q)^0],[0*Z(q),Z(q)^0]]; | ||
| ## retry until RecogNaturalSL2 returns generators matching the standard form | ||
| ## TODO: Perhaps remove this for-loop |
There was a problem hiding this comment.
Yes definitely. Why is it even here? Does Frank's code sometimes fail?
[ some time later ]
Aha indeed, for even q, Frank's code is not quite right. Maybe @frankluebeck can suggest a fix. Here's a reproducer:
q:=8;;
G:=SL(2,q);;
res:=RECOG.RecogNaturalSL2(G,q);
nicegens :=List(res[1],a->ResultOfStraightLineProgram(a,GeneratorsOfGroup(G)));
diag := nicegens[1]^res[2];
u1 := nicegens[2]^res[2];
u2 := nicegens[3]^res[2];
Display(diag);
Display(u1);
Display(u2);
If one plugs in an odd q this works nicely, but for even q only sometimes. Indeed, the test code below tries it 1000 timesl for me it worked in just 242 cases (obviously it will fluctuate depending on the RNG seed):
q:=8;;
G:=SL(2,q);;
good:=0;;
for i in [1..1000] do
res:=RECOG.RecogNaturalSL2(G,q);
nicegens :=List(res[1],a->ResultOfStraightLineProgram(a,GeneratorsOfGroup(G)));
diag := nicegens[1]^res[2];
u1 := nicegens[2]^res[2];
u2 := nicegens[3]^res[2];
if IsDiagonalMat(diag) and IsLowerTriangularMat(u1) and IsUpperTriangularMat(u2) then
good := good + 1;
fi;
od;
In the meantime, I suggest we keep using RECOG.RecogniseSL2NaturalEvenChar for even q until someone has a fix for Frank's code.
Co-authored-by: Martin Wagner <martin.wagner.dev@gmail.com>
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Martin Wagner <martin.wagner.dev@gmail.com>
74e54f9 to
10a6ec2
Compare
Added Frank Lübeck's RecogNaturalSL2 algorithm as well as ConRecogNaturalSL2, which calls it and converts the output to the same format as RECOG.RecogniseSL2NaturalEvenChar / RECOG.RecogniseSL2NaturalOddCharUsingBSGS. ConRecogNaturalSL2 retries up to 100 times until the correct generators are found (usually takes very few attempts, i.e. 100 is a very high bound).
Also added test_ConRecogNaturalSL2 for testing: it accepts either a list of prime powers or an empty list — in the latter case a preset list of prime powers is tested automatically.
Note RecogNaturalSL2 does not work for q=2,3,5. In this case the old functions are called.