/usr/share/gap/lib/rwsgrp.gi is in gap-libs 4r7p9-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 | #############################################################################
##
#W rwsgrp.gi GAP Library Frank Celler
##
##
#Y Copyright (C) 1996, Lehrstuhl D für Mathematik, RWTH Aachen, Germany
#Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y Copyright (C) 2002 The GAP Group
##
## This file contains the generic methods for groups defined by rewriting
## systems.
##
#############################################################################
##
#M ElementByRws( <fam>, <elm> )
##
InstallMethod( ElementByRws,
true,
[ IsElementsFamilyByRws, IsObject ],
0,
function( fam, elm )
elm := [ Immutable(elm) ];
return Objectify( fam!.defaultType, elm );
end );
##
## Some collectors, for example a Deep Thought collector, store the
## rhs of conjugate and power relations as generators exponent lists.
## If ElementByRws() is called for those rhs, we need to convert them
## first to words in the appropriate free group.
##
InstallMethod( ElementByRws,
true,
[ IsElementsFamilyByRws, IsList ],
0,
function( fam, list )
local elm, freefam;
freefam := UnderlyingFamily( fam!.rewritingSystem );
elm := ObjByExtRep( freefam, list );
elm := [ Immutable(elm) ];
return Objectify( fam!.defaultType, elm );
end );
#############################################################################
##
#M PrintObj( <elm-by-rws> )
##
InstallMethod( PrintObj,
true,
[ IsMultiplicativeElementWithInverseByRws and IsPackedElementDefaultRep ],
0,
function( obj )
Print( obj![1] );
end );
#############################################################################
##
#M UnderlyingElement( <elm-by-rws> )
##
InstallMethod( UnderlyingElement,
true,
[ IsMultiplicativeElementWithInverseByRws and IsPackedElementDefaultRep ],
0,
function( obj )
return obj![1];
end );
#############################################################################
##
#M ExtRepOfObj( <elm-by-rws> )
##
InstallMethod( ExtRepOfObj,
true,
[ IsMultiplicativeElementWithInverseByRws ],
0,
function( obj )
return ExtRepOfObj( UnderlyingElement( obj ) );
end );
#############################################################################
##
#M Comm( <elm-by-rws>, <elm-by-rws> )
##
InstallMethod( Comm,
"rws-element, rws-element",
IsIdenticalObj,
[ IsMultiplicativeElementWithInverseByRws,
IsMultiplicativeElementWithInverseByRws ],
0,
function( left, right )
local fam;
fam := FamilyObj(left);
return ElementByRws( fam, ReducedComm( fam!.rewritingSystem,
UnderlyingElement(left), UnderlyingElement(right) ) );
end );
#############################################################################
##
#M InverseOp( <elm-by-rws> )
##
InstallMethod( InverseOp,
"rws-element",
true,
[ IsMultiplicativeElementWithInverseByRws ],
0,
function( obj )
local fam;
fam := FamilyObj(obj);
return ElementByRws( fam, ReducedInverse( fam!.rewritingSystem,
UnderlyingElement(obj) ) );
end );
#############################################################################
##
#M LeftQuotient( <elm-by-rws>, <elm-by-rws> )
##
InstallMethod( LeftQuotient,
"rws-element, rws-element",
IsIdenticalObj,
[ IsMultiplicativeElementWithInverseByRws,
IsMultiplicativeElementWithInverseByRws ],
0,
function( left, right )
local fam;
fam := FamilyObj(left);
return ElementByRws( fam, ReducedLeftQuotient( fam!.rewritingSystem,
UnderlyingElement(left), UnderlyingElement(right) ) );
end );
#############################################################################
##
#M OneOp( <elm-by-rws> )
##
InstallMethod( OneOp,
"rws-element",
true,
[ IsMultiplicativeElementWithInverseByRws ],
0,
function( obj )
local fam;
fam := FamilyObj(obj);
return ElementByRws( fam, ReducedOne(fam!.rewritingSystem) );
end );
#############################################################################
##
#M Quotient( <elm-by-rws>, <elm-by-rws> )
##
InstallMethod( \/,
"rws-element, rws-element",
IsIdenticalObj,
[ IsMultiplicativeElementWithInverseByRws,
IsMultiplicativeElementWithInverseByRws ],
0,
function( left, right )
local fam;
fam := FamilyObj(left);
return ElementByRws( fam, ReducedQuotient( fam!.rewritingSystem,
UnderlyingElement(left), UnderlyingElement(right) ) );
end );
#############################################################################
##
#M <elm-by-rws> * <elm-by-rws>
##
InstallMethod( \*,
"rws-element * rws-element",
IsIdenticalObj,
[ IsMultiplicativeElementWithInverseByRws,
IsMultiplicativeElementWithInverseByRws ],
0,
function( left, right )
local fam;
fam := FamilyObj(left);
return ElementByRws( fam, ReducedProduct( fam!.rewritingSystem,
UnderlyingElement(left), UnderlyingElement(right) ) );
end );
#############################################################################
##
#M <elm-by-rws> ^ <elm-by-rws>
##
InstallMethod( \^,
"rws-element ^ rws-element",
IsIdenticalObj,
[ IsMultiplicativeElementWithInverseByRws,
IsMultiplicativeElementWithInverseByRws ],
0,
function( left, right )
local fam;
fam := FamilyObj(left);
return ElementByRws( fam, ReducedConjugate( fam!.rewritingSystem,
UnderlyingElement(left), UnderlyingElement(right) ) );
end );
#############################################################################
##
#M <elm-by-rws> ^ <int>
##
InstallMethod( \^,
"rws-element ^ int",
IsIdenticalObj,
[ IsMultiplicativeElementWithInverseByRws,
IsInt ],
0,
function( left, right )
local fam;
fam := FamilyObj(left);
return ElementByRws( fam, ReducedPower( fam!.rewritingSystem,
UnderlyingElement(left), right ) );
end );
#############################################################################
##
#M <elm-by-rws> = <elm-by-rws>
##
InstallMethod( \=,
IsIdenticalObj,
[ IsMultiplicativeElementWithInverseByRws,
IsMultiplicativeElementWithInverseByRws ],
0,
function( left, right )
return UnderlyingElement(left) = UnderlyingElement(right);
end );
#############################################################################
##
#M <elm-by-rws> < <elm-by-rws>
##
InstallMethod( \<,
IsIdenticalObj,
[ IsMultiplicativeElementWithInverseByRws,
IsMultiplicativeElementWithInverseByRws ],
0,
function( left, right )
return UnderlyingElement(left) < UnderlyingElement(right);
end );
#############################################################################
##
#M MultiplicativeElementsWithInversesFamilyByRws( <rws> )
##
InstallMethod( MultiplicativeElementsWithInversesFamilyByRws,
true,
[ IsRewritingSystem and IsBuiltFromGroup ],
0,
function( rws )
local fam;
# create a new family in the category <IsElementsFamilyByRws>
fam := NewFamily(
"MultiplicativeElementsWithInversesFamilyByRws(...)",
IsMultiplicativeElementWithInverseByRws
and IsAssociativeElement,
IsElementsFamilyByRws );
# store the rewriting system
fam!.rewritingSystem := Immutable(rws);
# create the default type for the elements
fam!.defaultType := NewType( fam, IsPackedElementDefaultRep );
# that's it
return fam;
end );
#############################################################################
##
#M GroupByRws( <rws> )
##
InstallMethod( GroupByRws,
true,
[ IsRewritingSystem and IsBuiltFromGroup ],
0,
function( rws )
# it must be confluent
if not IsConfluent(rws) then
Error( "the rewriting system must be confluent" );
fi;
# use the no-check to do the work
return GroupByRwsNC(rws);
end );
#############################################################################
##
#M GroupByRwsNC( <rws> )
##
InstallMethod( GroupByRwsNC,"rewriting system", true,
[ IsRewritingSystem and IsBuiltFromGroup ], 100,
function( rws )
local pows,conjs,fam, gens, g, id, grp,defpcgs,i;
# give the rewriting system a chance to optimise itself
ReduceRules(rws);
# construct a new family containing the group elements
fam := MultiplicativeElementsWithInversesFamilyByRws(rws);
# construct the generators
gens := [];
for g in GeneratorsOfRws(rws) do
Add( gens, ElementByRws( fam, ReducedForm( rws, g ) ) );
od;
id := ElementByRws( fam, ReducedOne(rws) );
# and a group
grp := GroupByGenerators( gens, id );
# it is the whole family
SetIsWholeFamily( grp, true );
# check the true methods
if HasIsFinite( rws ) then
SetIsFinite( grp, IsFinite( rws ) );
fi;
if IsPolycyclicCollector( rws ) then
defpcgs:=DefiningPcgs( ElementsFamily(FamilyObj(grp)) );
SetFamilyPcgs( grp, defpcgs);
SetHomePcgs( grp, defpcgs);
SetGroupOfPcgs(defpcgs,grp);
if HasIsFiniteOrdersPcgs(defpcgs) and IsFiniteOrdersPcgs(defpcgs) then
SetSize(grp,Product(RelativeOrders(defpcgs)));
if HasRelativeOrders(rws)
and not ForAll(RelativeOrders(rws),IsPrimeInt) then
Info(InfoWarning,1,
"You are creating a Pc group with non-prime relative orders.");
Info(InfoWarning,1,
"Many algorithms require prime relative orders.");
Info(InfoWarning,1,"Use `RefinedPcGroup' to convert.");
fi;
fi;
if IsSingleCollectorRep(rws) then
pows:=rws![SCP_POWERS];
conjs:=rws![SCP_CONJUGATES];
for i in [1..Length(pows)] do
if IsBound(pows[i]) then
# this certainly could be done better, if one knew more about rws
# than I do. AH
defpcgs!.powers[i]:=ExponentsOfPcElement(defpcgs,
ElementByRws(fam,pows[i]));
else
defpcgs!.powers[i]:=defpcgs!.zeroVector;
fi;
od;
for pows in [1..Length(conjs)] do
for i in [1..Length(conjs[pows])] do
if IsBound(conjs[pows][i]) then
# this certainly could be done better, if one knew more about rws
# than I do. AH
defpcgs!.conjugates[pows][i]:=ExponentsOfPcElement(defpcgs,
ElementByRws(fam,conjs[pows][i]));
else
defpcgs!.conjugates[pows][i]:=ExponentsOfPcElement(defpcgs,
defpcgs[pows]);
fi;
od;
od;
fi;
fi;
# that's it
return grp;
end );
#############################################################################
##
#E
|