[GAP Forum] Is it possible to step through the program, like GNU GDB debugger, against built-in functions(ex. DerivedSubgroup, ClosureSubgroupNC )?
Alexander Konovalov
alexk at mcs.st-andrews.ac.uk
Wed Sep 17 14:07:19 BST 2014
On 17 Sep 2014, at 13:57, buynnnmmm1 at yahoo.co.jp wrote:
> Dear Alexander Konovalov,
>
> Thank you very much for your help.
> I will be able to do what I would like to do with the way you taught me, embeded Err("Message")s in codes.
>
>> What is does is that it calls TryPcgsPermGroup and then checks if it returns the
>> object which is IsPcgs (polycyclic generating system, see
>> http://www.gap-system.org/Manuals/doc/ref/chap45.html). If that calculation is
>> not successful, the group is not solvable, otherwise it is. Now you may be
>> interested to find the (undocumented!) function TryPcgsPermGroup which does the
>> actual job, see for any comments in the code, etc.
>
>
> I have not try to read the source TryPcgsPermGroup and IsPcgs yet.
>
> Source code of IsSolvable was also included in the lib / grp.gi and lib / grp.gd.
> It is very easy to understand for me.
>
> myIsSolvable:=function ( x )
> local d;
> d := DerivedSeries( x );
> return IsTrivial( d[Size( d )] );
> end
>
>
> gap> List([1..30], x -> myIsSolvable(SymmetricGroup(x))) = List([1..30], x -> IsSolvable(SymmetricGroup(x)));
> true
>
> For Symmetric Group, the same results have been obtained.
> So I'm going to try to do withmyIsSolvable function that uses the DerivedSeries function.
>
> There was a difference of more than twice the run time to IsSolvable of built-in and myIsSolvable Taking the profile.
>
> Built-in IsSolved Would has become the source code I hard to understand in order to increase the execution speed?
>
>
Not really - the method for IsSolvable did not evolve from the code similar to myIsSolvable at all.
Perhaps the key is to read about GAP method selection and learn the concept of methods as bundles of functions:
http://www.gap-system.org/Manuals/doc/tut/chap8.html#X7AEED9AB824CD4DA
- that is, IsSolvable(G) will select the best available method to apply to G, taking into account what's known about G at the moment. With myIsSolvable, you enforce the calculation of DerivedSeries, while some of the methods may need not to know the derived series at all to give an answer. The profile below just illustrates this, since the number of methods involved in the calls to GAP's IsSolvable is much smaller.
Best wishes
Alexander
> gap> ProfileGlobalFunctions( true );
> gap> ProfileOperationsAndMethods( true );
> gap> List( [1..30], x -> IsSolvable(SymmetricGroup(x))) ;
> [ true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
> false, false, false, false, false, false, false, false, false, false, false ]
> gap> ProfileGlobalFunctions( false );
> gap> ProfileOperationsAndMethods( false );
> gap> DisplayProfile();
> count self/ms chld/ms stor/kb chld/kb package function
> 56 0 32 6 786 GAP TryPcgsPermGroup
> 56 0 32 9 794 (oprt.) IsSolvableGroup
> 30 0 32 0 804 (oprt.) IsSolvable
> 28 0 32 0 794 GAP IsSolvableGroup: for permgrp
> 156491 40 0 741 15 (oprt.) Add
> 3 52 0 70 0 SortParallel: for two dense and mutable lists
> 574 16 40 2043 988 GAP List
> 4 4 80 96 213 (oprt.) Sortex
> 4 60 52 72 70 (oprt.) SortParallel
> 2028 272 0 0 0 (oprt.) Position
> 72 2324 OTHER
> 516 5365 TOTAL
> gap> ProfileGlobalFunctions( true );
> gap> ProfileOperationsAndMethods( true );
> gap> List( [1..30], x -> myIsSolvable(SymmetricGroup(x))) ;
> [ true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
> false, false, false, false, false, false, false, false, false, false, false ]
> gap> ProfileGlobalFunctions( false );
> gap> ProfileOperationsAndMethods( false );
> gap> DisplayProfile();
> count self/ms chld/ms stor/kb chld/kb package function
> 11686 0 0 0 0 CanComputeIsSubset: default: no, unless identical
> 12708 4 4 198 0 GAP IsOne: for a multiplicative-element-with-one
> 18151 8 4 0 0 (oprt.) Tester(IsAssociative)
> 12708 20 0 0 198 (oprt.) IsOne
> 15776 12 4 0 0 OneImmutable: system getter
> 21144 16 4 29 0 GeneratorsOfMagmaWithInverses: system getter
> 17646 12 12 18 173 (oprt.) Representative: for magma-with-one with known one
> 382 0 32 5 269 (oprt.) Setter(ParentAttr)
> 21144 16 16 18 29 (oprt.) FreeGeneratorsOfFpGroup: for a free group
> 1 0 32 70 70 GAP Sortex: for a mutable list
> 3391 8 24 92 191 GAP SmallestMovedPoint: for a collection of permutations
> 382 0 32 7 12 GAP Setter(ParentAttr): method that calls 'UseSubsetRelation'
> 8681 4 40 0 337 (oprt.) SmallestMovedPoint
> 43634 16 36 1985 382 GAP ForAll
> 185602 52 0 863 2 (oprt.) Add
> 757 44 16 17 0 GAP UseSubsetRelation: default method that checks maintenances and then returns *
> 757 0 60 7 17 (oprt.) UseSubsetRelation
> 53823 68 4 11517 0 GAP InverseRepresentative
> 3 76 0 70 0 SortParallel: for two dense and mutable lists
> 9945 20 72 194 12950 GAP in: for a permutation, and a permutation group
> 5564 44 60 3915 2410 GAP ChooseNextBasePoint
> 4 0 108 113 254 (oprt.) Sortex
> 224034 116 0 0 0 (oprt.) NumberOp: for a dense list
> 5564 84 60 498 168 GAP AddGeneratorsExtendSchreierTree
> 5 76 76 113 70 (oprt.) SortParallel
> 12526 280 4 0 0 (oprt.) Position
> 94315 472 8 89804 0 GAP SiftedPermutation
> 5564 184 804 8789 94952 GAP StabChainStrong
> 265 8 1104 77 107182 GAP ClosureGroup: permgroup, elements, options
> 265 4 1112 0 107259 (oprt.) ClosureGroup
> 62 0 1296 0 122301 (oprt.) DerivedSubgroup
> 56 12 1284 162 122086 GAP DerivedSubgroup: permgrps
> 30 0 1316 5 122489 GAP DerivedSeriesOfGroup: generic method for groups
> 30 0 1316 0 122505 (oprt.) DerivedSeries
> 30 0 1316 0 122505 (oprt.) DerivedSeriesOfGroup
> 26 36 1324 2853 122729 GAP List
> 160 6531 OTHER
> 1852 127963 TOTAL
>
>
> With best regards
> buynnnmmm1
>
>
>
> ----- Original Message -----
>> From: Alexander Konovalov <alexk at mcs.st-andrews.ac.uk>
>> To: buynnnmmm1 at yahoo.co.jp
>> Cc: GAP Forum <forum at gap-system.org>
>> Date: 2014/9/17, Wed 20:19
>> Subject: Re: [GAP Forum] Is it possible to step through the program, like GNU GDB debugger, against built-in functions(ex. DerivedSubgroup, ClosureSubgroupNC )?
>>
>> On 16 Sep 2014, at 22:52, buynnnmmm1 at yahoo.co.jp wrote:
>>
>>> Dear GAP forum,
>>>
>>> Is it possible to set break points against built-in functions (ex.
>> DerivedSubgroup)?
>>>
>>> Is it possible to step through the program, like GNU GDB debugger, against
>> built-in functions(ex. DerivedSubgroup, ClosureSubgroupNC )?
>>>
>>> Because I am a beginner the group theory , I would to examine in detail
>> what functions are doing in what procedure .
>>>
>>> I check http://www.gap-system.org/Manuals/doc/ref/chap7.html, but I cannot
>> find the function that set break points or step through the function.
>>
>> No, there is no such functionality, but there are workarounds and alternatives.
>>
>> First, you can add the line like
>>
>> Error("Break point some text which you want to display...");
>>
>> in the code, and then you will be able to investigate local variables from the
>> break loop - see http://www.gap-system.org/Manuals/doc/ref/chap6.html
>>
>> Second, you already know from your previous post how to find the code of the
>> function. Since GAP is an interpreted language, you may try to paste the code of
>> the function into your session line by line and see what happens.
>>
>> Finally, YMMV (your mileage may vary): looking at the method below for
>> IsSolvableGroup itself will likely not give an insight into the solvability of
>> groups, it will just point to some other procedure:
>>
>>> gap> g := SymmetricGroup(5);
>>> Sym( [ 1 .. 5 ] )
>>> gap> ApplicableMethod(IsSolvableGroup,[g]);
>>> function( G ) ... end
>>> gap> f := last;
>>> function( G ) ... end
>>> gap> Print(f);
>>> function ( G )
>>> local pcgs;
>>> pcgs := TryPcgsPermGroup( G, false, false, true );
>>> if IsPcgs( pcgs ) then
>>> SetIndicesEANormalSteps( pcgs, pcgs!.permpcgsNormalSteps );
>>> SetIsPcgsElementaryAbelianSeries( pcgs, true );
>>> if not HasPcgs( G ) then
>>> SetPcgs( G, pcgs );
>>> fi;
>>> if not HasPcgsElementaryAbelianSeries( G ) then
>>> SetPcgsElementaryAbelianSeries( G, pcgs );
>>> fi;
>>> return true;
>>> else
>>> return false;
>>> fi;
>>> return;
>>> end
>>
>>
>> What is does is that it calls TryPcgsPermGroup and then checks if it returns the
>> object which is IsPcgs (polycyclic generating system, see
>> http://www.gap-system.org/Manuals/doc/ref/chap45.html). If that calculation is
>> not successful, the group is not solvable, otherwise it is. Now you may be
>> interested to find the (undocumented!) function TryPcgsPermGroup which does the
>> actual job, see for any comments in the code, etc.
>>
>> Best wishes
>> Alexander
>>
More information about the Forum
mailing list