home *** CD-ROM | disk | FTP | other *** search
/ Math Solutions 1995 October / Math_Solutions_CD-ROM_Walnut_Creek_October_1995.iso / pc / mac / discrete / lib / grpelms.g < prev    next >
Encoding:
Text File  |  1993-05-05  |  7.3 KB  |  245 lines

  1. #############################################################################
  2. ##
  3. #A  grpelms.g                   GAP library                      Frank Celler
  4. ##
  5. #A  @(#)$Id: grpelms.g,v 3.11 1992/12/16 19:47:27 martin Rel $
  6. ##
  7. #Y  Copyright 1990-1992,  Lehrstuhl D fuer Mathematik,  RWTH Aachen,  Germany
  8. ##
  9. ##  This file contains all  functions  and  operations  for  groups elements.
  10. ##
  11. #H  $Log: grpelms.g,v $
  12. #H  Revision 3.11  1992/12/16  19:47:27  martin
  13. #H  replaced quoted record names with escaped ones
  14. #H
  15. #H  Revision 3.10  1992/03/19  15:42:13  martin
  16. #H  added basic groups
  17. #H
  18. #H  Revision 3.9  1992/02/07  15:34:08  fceller
  19. #H  Initial GAP 3.1 release.
  20. #H
  21. #H  Revision 3.8  1992/01/29  10:46:13  martin
  22. #H  moved 'GroupOps.Order' to the end to avoid reading 'group.g' to early
  23. #H
  24. #H  Revision 3.7  1992/01/29  09:09:38  martin
  25. #H  changed 'Order' to take two arguments, group and element
  26. #H
  27. #H  Revision 3.6  1992/01/16  14:01:48  martin
  28. #H  made sure that 'operatio.g' is loaded whenever 'grpelms.g' is loaded
  29. #H
  30. #H  Revision 3.1  1991/09/09  10:12:03  fceller
  31. #H  Initial release under RCS.
  32. ##
  33.  
  34.  
  35. #############################################################################
  36. ##
  37. #F  IsGroupElement( <g> ) . . . . . . .  test if an object is a group element
  38. ##
  39. IsGroupElement := function ( g )
  40.     return    IsPerm( g )
  41.            or IsWord( g )
  42.            or IsAgWord( g )
  43.            or IsMat( g )
  44.            or IsRec( g ) and IsBound(g.isGroupElement) and g.isGroupElement;
  45. end;
  46.  
  47.  
  48. #############################################################################
  49. ##
  50. #V  GroupElements . . . . . . . . . . . . . . .  domain of all group elements
  51. #V  GroupElementsOps  .  operation record of the domain of all group elements
  52. ##
  53. ##  'GroupElements' is the domain of all group  elements, i.e., permutations,
  54. ##  abstract  words, words in  solvable  groups,  matrices, and records  that
  55. ##  implement group elements.  Note that 'GroupElements' is not a group.
  56. ##
  57. ##  'GroupElementsOps' is   the operations  record for   the  'GroupElements'
  58. ##  domain.   Other  domains that  consist  of group  elements,  for  example
  59. ##  'Permutations' and 'Matrices' inherit from this operations record.
  60. ##
  61. ##  The most important function defined for 'GroupElements' is 'Group', i.e.,
  62. ##  'GroupElements' knowns how to make a group from a list of elements.
  63. ##
  64. GroupElements                   := rec( );
  65.  
  66. GroupElements.isDomain          := true;
  67.  
  68. GroupElements.name              := "GroupElements";
  69.  
  70. GroupElements.isFinite          := false;
  71. GroupElements.size              := "infinity";
  72.  
  73. GroupElements.operations        := Copy( DomainOps );
  74. GroupElementsOps                := GroupElements.operations;
  75.  
  76. GroupElementsOps.\in := function ( g, GroupElements )
  77.     return    IsPerm( g )
  78.            or IsWord( g )
  79.            or IsAgWord( g )
  80.            or IsMat( g )
  81.            or IsRec( g ) and IsBound(g.isGroupElement) and g.isGroupElement;
  82. end;
  83.  
  84. GroupElementsOps.Order := function ( G, g )
  85.     local   ord,        # order of <g>, result
  86.             pow,        # power of <g>
  87.             id;         # identity of <G>
  88.  
  89.     id  := g^0;
  90.     pow := g;
  91.     ord := 1;
  92.     while pow <> id  do
  93.         pow := pow * g;
  94.         ord := ord + 1;
  95.     od;
  96.     return ord;
  97. end;
  98.  
  99.  
  100. #############################################################################
  101. ##
  102. #F  GroupElementOps . . . . . . . operation record for generic group elements
  103. ##
  104. GroupElementOps         := rec( );
  105.  
  106. GroupElementOps.\= := function ( a, b )
  107.     if      IsRec( a ) and IsBound( a.isGroupElement ) and a.isGroupElement
  108.         and IsRec( b ) and IsBound( b.isGroupElement ) and b.isGroupElement
  109.         and a.domain = b.domain
  110.     then
  111.         return a.element = b.element;
  112.     else
  113.         return false;
  114.     fi;
  115. end;
  116.  
  117. GroupElementOps.\< := function ( a, b )
  118.     if      IsRec( a ) and IsBound( a.isGroupElement ) and a.isGroupElement
  119.         and IsRec( b ) and IsBound( b.isGroupElement ) and b.isGroupElement
  120.     then
  121.         if a.domain = b.domain  then
  122.             return a.element < b.element;
  123.         else
  124.             return a.domain < b.domain;
  125.         fi;
  126.     elif    IsRec( a ) and IsBound( a.isGroupElement ) and a.isGroupElement
  127.     then
  128.         return not IsGroupElement( b );
  129.     elif    IsRec( b ) and IsBound( b.isGroupElement ) and b.isGroupElement
  130.     then
  131.         return IsGroupElement( a );
  132.     else
  133.         Error("panic, either <a> or <b> must be a group element");
  134.     fi;
  135. end;
  136.  
  137. GroupElementOps.\* := function ( a, b )
  138.     Error("no default method to multiply generic group elements");
  139. end;
  140.  
  141. GroupElementOps.\/ := function ( a, b )
  142.     return a * b^-1;
  143. end;
  144.  
  145. GroupElementOps.\mod := function ( a, b )
  146.     return a^-1 * b;
  147. end;
  148.  
  149. GroupElementOps.\^ := function ( a, b )
  150.     Error("no default method to multiply generic group elements");
  151. end;
  152.  
  153. GroupElementOps.Comm := function ( a, b )
  154.     return a^-1 * b^-1 * a * b;
  155. end;
  156.  
  157. GroupElementOps.Print := function ( a )
  158.     Print( "GroupElement( ", a.element, " )" );
  159. end;
  160.  
  161.  
  162. #############################################################################
  163. ##
  164. #F  Order( <g> )  . . . . . . . . . . . . . . . . . order of an group element
  165. ##
  166. Order := function ( G, g )
  167.     return G.operations.Order( G, g );
  168. end;
  169.  
  170. GroupOps.Order := function ( G, g )
  171.     local   ord,        # order of <g>, result
  172.             pow,        # power of <g>
  173.             id;         # identity of <G>
  174.  
  175.     id := G.identity;
  176.     pow := g;
  177.     ord := 1;
  178.     while pow <> id  do
  179.         pow := pow * g;
  180.         ord := ord + 1;
  181.     od;
  182.     return ord;
  183. end;
  184.  
  185.  
  186. #############################################################################
  187. ##
  188. #F  GroupElementsOps.CyclicGroup(<D>,<n>) . . . . . . . . . . .  cyclic group
  189. #F  GroupElementsOps.AbelianGroup(<D>,<ords>) . . . . . . . . . abelian group
  190. #F  GroupElementsOps.ElementaryAbelianGroup(<D>,<n>) elementary abelian group
  191. #F  GroupElementsOps.DihedralGroup(<D>,<n>) . . . . . . . . .  dihedral group
  192. #F  GroupElementsOps.PolyhedralGroup(<D>,<p>,<q>) . . . . .  polyhedral group
  193. #F  GroupElementsOps.AlternatingGroup(<D>,<n>)  . . . . . . alternating group
  194. #F  GroupElementsOps.SymmetricGroup(<D>,<n>)  . . . . . . . . symmetric group
  195. ##
  196. GroupElementsOps.CyclicGroup := function ( D, n )
  197.     Error( "sorry, cannot compute cyclic group for this domain" );
  198. end;
  199.  
  200. GroupElementsOps.AbelianGroup := function ( D, ords )
  201.     return DirectProduct( List( ords, x -> CyclicGroup( D, x ) ) );
  202. end;
  203.  
  204. GroupElementsOps.ElementaryAbelianGroup := function ( D, n )
  205.     local   f,  C;
  206.  
  207.     f := Factors( n );
  208.     C := CyclicGroup( D, f[ 1 ] );
  209.     return DirectProduct( List( f, x -> C ) );
  210.  
  211. end;
  212.  
  213. GroupElementsOps.DihedralGroup := function ( D, n )
  214.     Error("sorry, cannot compute dihedral group for this domain");
  215. end;
  216.  
  217. GroupElementsOps.PolyhedralGroup := function ( D, n )
  218.     Error("sorry, cannot compute polyhedral group for this domain");
  219. end;
  220.  
  221. GroupElementsOps.AlternatingGroup := function ( D, n )
  222.     Error("sorry, cannot compute alternating group for this domain");
  223. end;
  224.  
  225. GroupElementsOps.SymmetricGroup := function ( D, n )
  226.     Error("sorry, cannot compute symmetric group for this domain");
  227. end;
  228.  
  229.  
  230. #############################################################################
  231. ##
  232. #E  Emacs . . . . . . . . . . . . . . . . . . . . . . . local emacs variables
  233. ##
  234. ##  Local Variables:
  235. ##  mode:               outline
  236. ##  outline-regexp:     "#F\\|#V\\|#E"
  237. ##  fill-column:        73
  238. ##  fill-prefix:        "##  "
  239. ##  eval:               (hide-body)
  240. ##  End:
  241. ##
  242.  
  243.  
  244.  
  245.