/usr/share/gap/pkg/tomlib/gap/stdgen.gi is in gap-table-of-marks 1r2p6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | #############################################################################
##
#W stdgen.gi GAP library Thomas Breuer
##
#H @(#)$Id: stdgen.gi,v 1.1 2002/02/20 17:21:29 gap Exp $
##
#Y (C) 1999 School Math and Comp. Sci., University of St. Andrews, Scotland
##
## This file contains the implementations needed for dealing with standard
## generators of finite groups.
##
Revision.stdgen_gi :=
"@(#)$Id: stdgen.gi,v 1.1 2002/02/20 17:21:29 gap Exp $";
#############################################################################
##
#F HumanReadableDefinition( <info> )
##
InstallGlobalFunction( HumanReadableDefinition, function( info )
local nrgens,
alpha,
lalpha,
generators,
i,
m,
gensstring,
nraux,
auxnames,
description,
script,
len,
line,
word,
pos,
str,
j,
strline,
linelen;
# Check the argument.
if not ( IsRecord( info ) and IsBound( info.script ) ) then
Error( "<info> must be a record with a component `script'" );
elif not IsBound( info.description ) then
# Get names of the standard generators.
alpha:= [ "a","b","c","d","e","f","g","h","i","j","k","l","m",
"n","o","p","q","r","s","t","u","v","w","x","y","z" ];
lalpha:= Length( alpha );
if not IsBound( info.generators ) then
nrgens:= Number( info.script,
line -> Length( line ) <= 3 and IsInt( line[2] ) );
generators:= [];
for i in [ 1 .. nrgens ] do
if i <= lalpha then
generators[i]:= alpha[i];
else
m:= (i-1) mod lalpha + 1;
generators[i]:= Concatenation( alpha[m],
String( ( i - m ) / lalpha ) );
fi;
od;
gensstring:= "";
for i in generators do
Append( gensstring, i );
Append( gensstring, ", " );
od;
Unbind( gensstring[ Length( gensstring ) ] );
Unbind( gensstring[ Length( gensstring ) ] );
info.generators:= gensstring;
else
gensstring:= info.generators;
generators:= SplitString( gensstring, ",", " " );
nrgens:= Length( generators );
fi;
# Get the names of auxiliary generators needed.
nraux:= Number( info.script,
line -> Length( line ) = 3 and IsInt( line[2] ) );
if nrgens + nraux <= lalpha then
auxnames:= alpha{ [ lalpha-nraux+1 .. lalpha ] };
if not IsEmpty( Intersection( generators, auxnames ) ) then
auxnames:= List( [ 1 .. nraux ],
i -> Concatenation( "X", String(i) ) );
fi;
else
auxnames:= List( [ 1 .. nraux ],
i -> Concatenation( "X", String(i) ) );
fi;
nraux:= 1;
# Initialize the result string.
description:= "";
# Scan the script linearly.
script:= info.script;
len:= Length( script );
for i in [ 1 .. len ] do
line:= script[i];
if IsList( line[2] ) and IsString( line[2][1] ) then
# condition line.
word:= "";
linelen:= Length( line[1] );
for j in [ 1, 3 .. linelen-1 ] do
Append( word, generators[ line[1][j] ] );
if line[1][ j+1 ] = 2 then
Append( word, generators[ line[1][j] ] );
elif line[1][ j+1 ] <> 1 then
Add( word, '^' );
Append( word, String( line[1][ j+1 ] ) );
fi;
od;
str:= ShallowCopy( line[2] );
for j in [ 1 .. Length( str ) ] do
if not IsBound( str[j] ) then
str[j]:= word;
fi;
od;
strline:= Concatenation( str );
Add( strline, '=' );
Append( strline, String( line[3] ) );
elif Length( line ) = 2 then
# definition line
strline:= Concatenation( "|", generators[ line[1] ], "|=",
String( line[2] ) );
elif Length( line ) = 3 and IsInt( line[2] ) then
# definition line involving an auxiliary name
strline:= Concatenation( "|", auxnames[ nraux ], "|=",
String( line[2] ), ", ", auxnames[ nraux ],
"^", String( line[3] ), "=", generators[ line[1] ] );
nraux:= nraux+1;
else
# relation line
linelen:= Length( line );
if linelen = 3 then
strline:= Concatenation( "|",
StringOfResultOfStraightLineProgram( line[2],
generators{ line[1] } ),
"|=", String( line[3] ) );
else
strline:= "|";
for j in [ 1, 3 .. linelen-2 ] do
Append( strline, generators[ line[j] ] );
if line[ j+1 ] = 2 then
Append( strline, generators[ line[j] ] );
elif line[ j+1 ] <> 1 then
Add( strline, '^' );
Append( strline, String( line[ j+1 ] ) );
fi;
od;
Append( strline, "|=" );
Append( strline, String( line[ linelen ] ) );
fi;
fi;
Append( description, strline );
if i < len then
Append( description, ", " );
fi;
od;
# Store the value.
info.description:= description;
fi;
# Return the result.
return info.description;
end );
#############################################################################
##
#F ScriptFromString( <string> )
##
InstallGlobalFunction( ScriptFromString, function( string )
local gensnames,
gensorder,
lines,
nrlines,
k,
line,
pos,
int,
aux,
len,
pos2,
script,
nrgens,
i,
found,
list,
init,
initlen,
linelen,
scr,
try,
j,
word;
gensnames:= [];
gensorder:= [];
lines:= SplitString( string, ",", " " );
nrlines:= Length( lines );
# Loop over the lines.
script:= [];
nrgens:= 0;
k:= 1;
while k <= nrlines do
line:= lines[k];
# The names of the standard generators occur in lines
# starting not with `|' or lines containing neither `(' nor `^',
# and having a letter at position $2$ and a non-letter at position $3$.
if line[1] = '|' and IsAlphaChar( line[2] )
and not IsAlphaChar( line[3] )
and not ( '(' in line or '^' in line ) then
# This entry belongs to a definition
# (perhaps of an auxiliary element) via order.
pos:= Position( line, '|', 1 );
if pos = fail or line[ pos+1 ] <> '=' then
return fail;
fi;
Add( gensnames, line{ [ 2 .. pos-1 ] } );
int:= Int( line{ [ pos+2 .. Length( line ) ] } );
if int = fail then
return fail;
fi;
Add( gensorder, int );
len:= Length( gensnames );
nrgens:= nrgens + 1;
# Check whether this was an auxiliary element,
# and the next line (if there is one)
# defines a generator relative to this one.
if k < nrlines and lines[ k+1 ][1] <> '|'
and not '(' in lines[ k+1 ] then
# This line belongs to a definition via a power.
k:= k+1;
line:= lines[k];
pos:= Position( line, '^' );
if pos = fail then
return fail;
fi;
aux:= line{ [ 1 .. pos-1 ] };
if gensnames[ len ] <> aux then
return fail;
fi;
pos2:= Position( line, '=' );
int:= Int( line{ [ pos+1 .. pos2-1 ] } );
if int = fail then
return fail;
fi;
gensnames[ len ]:= line{ [ pos2+1 .. Length( line ) ] };
# Add the definition to the script.
Add( script, [ nrgens, gensorder[ len ], int ] );
else
# Add the definition to the script.
Add( script, [ nrgens, gensorder[ len ] ] );
fi;
else
pos:= Position( line, '=' );
if pos = fail then
return fail;
fi;
int:= Int( line{ [ pos+1 .. Length( line ) ] } );
if int = fail then
return fail;
fi;
# Check whether the line matches the first part of a function string.
found:= false;
for i in [ 1, 3 .. Length( StandardGeneratorsFunctions )-1 ] do
list:= StandardGeneratorsFunctions[ i+1 ];
init:= list[1];
initlen:= Length( init );
if init[ initlen ] <> '(' then
Error( "symbol <list> must enclose arguments in ( and )" );
elif init = line{ [ 1 .. initlen ] } then
# Find the word in question, and check it.
pos2:= initlen + 1;
linelen:= Length( line );
while pos2 <= linelen and not line[ pos2 ] in "()" do
pos2:= pos2 + 1;
od;
if pos2 <= linelen and line[ pos2 ] <> '(' then
word:= line{ [ initlen+1 .. pos2-1 ] };
try:= ShallowCopy( list );
for j in [ 1 .. Length( list ) ] do
if not IsBound( try[j] ) then
try[j]:= word;
fi;
od;
try:= Concatenation( try );
if try = line{ [ 1 .. pos-1 ] } then
scr:= [];
found:= StringToStraightLineProgram( word, gensnames, scr );
if found then
Add( script, [ scr[1][1], list, int ] );
fi;
fi;
fi;
if found then
break;
fi;
fi;
od;
if not found then
# Check for a relation.
if line[1] <> '|' then
return fail;
fi;
pos:= Position( line, '=' );
if pos = fail then
return fail;
fi;
if line[ pos-1 ] <> '|' then
return fail;
fi;
int:= Int( line{ [ pos+1 .. Length( line ) ] } );
if int = fail then
return fail;
fi;
word:= [];
if not StringToStraightLineProgram( line{ [ 2 .. pos-2 ] },
gensnames, word ) then
return fail;
fi;
# Create a straight line program if brackets were found.
if Length( word ) = 1 then
word:= word[1][1];
Add( word, int );
Add( script, word );
else
Add( script, [ [ 1 .. Length( gensnames ) ],
StraightLineProgram( word, Length( gensnames ) ),
int ] );
fi;
fi;
fi;
k:= k+1;
od;
# Return the result;
return script;
end );
#############################################################################
##
#V StandardGeneratorsFunctions
##
InstallValue( StandardGeneratorsFunctions, [] );
CentralizerOrder := function( G, g ) return Size( Centralizer( G, g ) ); end;
Append( StandardGeneratorsFunctions, [ CentralizerOrder, [ "|C(",,")|" ] ] );
#############################################################################
##
#F IsStandardGeneratorsOfGroup( <info>, <G>, <gens> )
##
InstallGlobalFunction( IsStandardGeneratorsOfGroup, function( info, G, gens )
local script,
i,
line,
g,
next,
linelen,
j;
# Initialize, and start the loop.
script:= info.script;
for i in [ 1 .. Length( script ) ] do
Info( InfoGroup, 3,
"StandardGenerators: inspecting line ", i );
line:= script[i];
if IsList( line[2] ) and IsString( line[2][1] ) then
# condition line.
# First compute the element to be checked.
if IsEmpty( line[1] ) then
g:= One( G );
elif not IsBound( gens[ line[1][1] ] ) then
return false;
else
g:= gens[ line[1][1] ];
if line[1][2] <> 1 then
g:= g ^ line[1][2];
fi;
for j in [ 3, 5 .. Length( line[1] ) - 1 ] do
if not IsBound( gens[ line[1][j] ] ) then
return false;
fi;
next:= gens[ line[1][j] ];
if line[1][ j+1 ] <> 1 then
next:= next ^ line[1][ j+1 ];
fi;
g:= g * next;
od;
fi;
# Next compute the value under the function, and compare.
if StandardGeneratorsFunctions[ Position(
StandardGeneratorsFunctions, line[2] ) - 1 ]( G,
g ) <> line[3] then
return false;
fi;
elif Length( line ) <= 3 and IsInt( line[2] ) then
# definition line
if not IsBound( gens[ line[1] ] )
or ( Length( line ) = 2 and Order( gens[ line[1] ] ) <> line[2] )
or ( Length( line ) = 3 and Order( gens[ line[1] ] )
<> line[2] / Gcd( line[2], line[3] ) ) then
return false;
fi;
else
# relation line
linelen:= Length( line );
if linelen = 3 then
if Order( ResultOfStraightLineProgram( line[2], gens{ line[1] } ) )
<> line[3] then
return false;
fi;
else
g:= gens[ line[1] ]^line[2];
for j in [ 3, 5 .. linelen-2 ] do
next:= gens[ line[j] ];
if line[ j+1 ] <> 1 then
next:= next^line[ j+1 ];
fi;
g:= g * next;
od;
if Order( g ) <> line[ linelen ] then
return false;
fi;
fi;
fi;
od;
# All conditions are satisfied.
return true;
end );
#############################################################################
##
#F StandardGeneratorsOfGroup( <info>, <G>[, <randfunc>] )
##
InstallGlobalFunction( StandardGeneratorsOfGroup, function( arg )
local info,
G,
randfunc,
gens,
script,
len,
i,
line,
g,
next,
linelen,
j;
# Get and check the arguments.
if Length( arg ) = 2 and IsRecord( arg[1] ) and IsGroup( arg[2] ) then
info := arg[1];
G := arg[2];
randfunc := PseudoRandom;
elif Length( arg ) = 3 and IsRecord( arg[1] ) and IsGroup( arg[2] )
and IsFunction( arg[3] ) then
info := arg[1];
G := arg[2];
randfunc := arg[3];
else
Error( "usage: StandardGenerators( <info>, <G>[, <randfunc>] )" );
fi;
# Initialize, and start the loop.
if not IsBound( info.script ) then
if not IsBound( info.description ) then
Error( "need at least a component `script' or `description'" );
else
info.script:= ScriptFromString( info.description );
fi;
fi;
script:= info.script;
len:= Length( script );
i:= 1;
gens:= [];
while i <= len do
Info( InfoGroup, 3,
"StandardGenerators: inspecting line ", i );
line:= script[i];
if IsList( line[2] ) and IsString( line[2][1] ) then
# condition line.
# First compute the element to be checked.
if IsEmpty( line[1] ) then
g:= One( G );
elif not IsBound( gens[ line[1][1] ] ) then
Error( "definition of ", Ordinal( line[1][1] ),
" generator missing before line ", i );
else
g:= gens[ line[1][1] ];
if line[1][2] <> 1 then
g:= g ^ line[1][2];
fi;
for j in [ 3, 5 .. Length( line[1] ) - 1 ] do
if not IsBound( gens[ line[1][j] ] ) then
Error( "definition of ", Ordinal( line[1][j] ),
" generator missing before line ", i );
fi;
next:= gens[ line[1][j] ];
if line[1][ j+1 ] <> 1 then
next:= next ^ line[1][ j+1 ];
fi;
g:= g * next;
od;
fi;
# Next compute the value under the function, and compare.
if StandardGeneratorsFunctions[ Position(
StandardGeneratorsFunctions, line[2] ) - 1 ]( G,
g ) <> line[3] then
gens:= [];
i:= 0;
fi;
elif Length( line ) <= 3 and IsInt( line[2] ) then
# definition line
if IsBound( gens[ line[1] ] ) then
Error( Ordinal( line[1] ),
" generator defined a second time in line ", i );
fi;
repeat
g:= randfunc( G );
until Order( g ) = line[2];
if IsBound( line[3] ) and line[3] <> 1 then
g:= g^line[3];
fi;
gens[ line[1] ]:= g;
else
# relation line
linelen:= Length( line );
if linelen = 3 then
g:= ResultOfStraightLineProgram( line[2], gens{ line[1] } );
else
g:= gens[ line[1] ]^line[2];
for j in [ 3, 5 .. linelen-2 ] do
g:= g * gens[ line[j] ]^line[ j+1 ];
od;
fi;
if Order( g ) <> line[ linelen ] then
gens:= [];
i:= 0;
fi;
fi;
# Inspect the next line.
i:= i + 1;
od;
# Return the result.
return gens;
end );
#############################################################################
##
#E
|