Ticket #14791: trac_14791_named_fpgroups.2.patch

File trac_14791_named_fpgroups.2.patch, 9.0 KB (added by dshurbert, 8 years ago)

Replacement patch

  • doc/en/reference/groups/index.rst

    # HG changeset patch
    # User Davis Shurbert <dshurbert@pugetsound.edu>
    # Date 1370586997 25200
    # Node ID 217e52b05ee8adf7f2017617fefc7864098b6910
    # Parent  3eb2e7e7c108f36b4f7621a92a127e197f0519fd
    Trac 14791: infrastructure for named finitely presented groups
    
    diff --git a/doc/en/reference/groups/index.rst b/doc/en/reference/groups/index.rst
    a b  
    1010   sage/groups/generic
    1111   sage/groups/free_group
    1212   sage/groups/finitely_presented
     13   sage/groups/finitely_presented_named
    1314   sage/groups/braid
    1415   sage/groups/abelian_gps/abelian_group
    1516   sage/groups/abelian_gps/values
  • sage/groups/all.py

    diff --git a/sage/groups/all.py b/sage/groups/all.py
    a b  
    2121lazy_import('sage.groups.affine_gps.affine_group', 'AffineGroup')
    2222lazy_import('sage.groups.affine_gps.euclidean_group', 'EuclideanGroup')
    2323
    24 import groups_catalog as groups
     24lazy_import('sage.groups', 'groups_catalog', 'groups')
  • new file sage/groups/finitely_presented_catalog.py

    diff --git a/sage/groups/finitely_presented_catalog.py b/sage/groups/finitely_presented_catalog.py
    new file mode 100644
    - +  
     1"""
     2Type ``groups.presentation.<tab>`` to access examples
     3of groups implemented as finite presentations (quotients of
     4free groups).
     5"""
     6
     7# groups imported here will be available
     8# via  groups.presentation.<tab>
     9#
     10# Do not use this file for code
     11#
     12# If you import a new group, then add an
     13# entry to the list in the module-level
     14# docstring of groups/groups_catalog.py############
     15
     16from finitely_presented_named import DihedralPresentation as Dihedral
     17from finitely_presented_named import CyclicPresentation as Cyclic
     18from finitely_presented_named import DiCyclicPresentation as DiCyclic
     19from finitely_presented_named import KleinFourPresentation as KleinFour
  • new file sage/groups/finitely_presented_named.py

    diff --git a/sage/groups/finitely_presented_named.py b/sage/groups/finitely_presented_named.py
    new file mode 100644
    - +  
     1"""
     2Named Finitely Presented Groups
     3
     4Construct groups of small order and "named" groups as quotients of free groups. These
     5groups are available through tab completion by typing ``groups.presentation.<tab>``
     6or by importing the required methods. Tab completion is made available through
     7Sage's :ref:`group catalog <sage.groups.groups_catalog>`. Some examples are engineered
     8from entries in [THOMAS-WOODS]_.
     9
     10Groups available as finite presentations:   
     11
     12-- Cyclic group, $C_n$ of order $n$
     13    - :func:`groups.presentation.Cyclic <sage.groups.finitely_presented_named.CyclicPresentation>`
     14
     15-- Dicyclic group, nonabelian groups of order $4n$ with a unique element of order 2
     16    - :func:`groups.presentation.DiCyclic <sage.groups.finitely_presented_named.DiCyclicPresentation>`
     17
     18-- Dihedral group, $D_n$ of order $2n$
     19    - :func:`groups.presentation.Dihedral <sage.groups.finitely_presented_named.DihedralPresentation>`
     20
     21-- Klein four group, `C_2 \\times C_2`
     22    - :func:`groups.presentation.KleinFour <sage.groups.finitely_presented_named.KleinFourPresentation>`
     23
     24AUTHORS:
     25
     26- Davis Shurbert (2013-06-21): initial version   
     27
     28EXAMPLES::
     29
     30    sage: groups.presentation.Cyclic(4)
     31    Finitely presented group < a | a^4 >
     32
     33You can also import the desired functions.::
     34
     35    sage: from sage.groups.finitely_presented_named import CyclicPresentation
     36    sage: CyclicPresentation(4)
     37    Finitely presented group < a | a^4 >
     38"""
     39#*****************************************************************************
     40#       Copyright (C) 2013 Davis Shurbert <davis.sprout@gmail.com>
     41#
     42#  Distributed under the terms of the GNU General Public License (GPL)
     43#                  http://www.gnu.org/licenses/
     44#*****************************************************************************
     45
     46from sage.rings.all      import Integer
     47from sage.groups.free_group import FreeGroup
     48from sage.groups.finitely_presented import FinitelyPresentedGroup
     49
     50def CyclicPresentation(n):
     51    """
     52    Build cyclic group of order `n` as a finitely presented group.
     53
     54    INPUT:
     55
     56    - ``n`` -- The order of the cyclic presentation to be returned.
     57
     58    OUTPUT:
     59
     60    The cyclic group of order `n` as finite presentation.
     61
     62    EXAMPLES::
     63
     64        sage: groups.presentation.Cyclic(10)
     65        Finitely presented group < a | a^10 >
     66        sage: n = 8; C = groups.presentation.Cyclic(n)
     67        sage: C.as_permutation_group().is_isomorphic(CyclicPermutationGroup(n))
     68        True
     69
     70    TESTS::
     71
     72        sage: groups.presentation.Cyclic(0)
     73        Traceback (most recent call last):
     74        ...
     75        ValueError: finitely presented group order must be positive
     76    """
     77    n = Integer(n)
     78    if n < 1:
     79        raise ValueError('finitely presented group order must be positive')
     80    F = FreeGroup( 'a' )
     81    rls = F([1])**n,
     82    return FinitelyPresentedGroup( F, rls )
     83
     84def DihedralPresentation(n):
     85    """
     86    Build the Dihedral group of order $2n$ as a finitely presented group.
     87   
     88    INPUT:
     89
     90    - ``n`` -- The size of the set that `D_n` is acting on.
     91
     92    OUTPUT:
     93
     94    Dihedral group of order `2n`.
     95 
     96    EXAMPLES::
     97
     98        sage: D = groups.presentation.Dihedral(7); D
     99        Finitely presented group < a, b | a^7, b^2, (a*b)^2 >
     100        sage: D.as_permutation_group().is_isomorphic(DihedralGroup(7))
     101        True
     102
     103    TESTS::
     104
     105        sage: n = 9
     106        sage: D = groups.presentation.Dihedral(n)
     107        sage: D.ngens() == 2
     108        True
     109        sage: groups.presentation.Dihedral(0)
     110        Traceback (most recent call last):
     111        ...
     112        ValueError: finitely presented group order must be positive
     113    """
     114    n = Integer( n )
     115    if n < 1:
     116        raise ValueError('finitely presented group order must be positive')
     117    F = FreeGroup([ 'a', 'b' ])
     118    rls = F([1])**n, F([2])**2, (F([1])*F([2]))**2
     119    return FinitelyPresentedGroup( F, rls )
     120
     121def DiCyclicPresentation(n):
     122    """
     123    Build the dicyclic group of order $4n$, for `n\geq 2`, as a finitely presented group.
     124   
     125    INPUT:
     126
     127    - ``n`` -- Possitive integer, 2 or greater, determining the order of the group (`4n`).
     128   
     129    OUTPUT:
     130
     131    The dicyclic group of order `4n` is defined by the presentation
     132
     133    .. MATH::
     134
     135        < a, x\mid a^{2n}=1, x^{2}=a^{n}, x^{-1}ax=a^{-1} >
     136
     137    .. note::
     138        This group is also available as a permutation group via
     139        :class:`groups.permutation.DiCyclic <sage.groups.perm_gps.permgroup_named.DiCyclicGroup>`.
     140
     141    EXAMPLES::
     142       
     143        sage: D = groups.presentation.DiCyclic(9); D
     144        Finitely presented group < a, b | a^18, b^2*a^-9, b^-1*a*b*a >
     145        sage: D.as_permutation_group().is_isomorphic(groups.permutation.DiCyclic(9))
     146        True
     147
     148    TESTS::
     149
     150        sage: Q = groups.presentation.DiCyclic(2)
     151        sage: Q.as_permutation_group().is_isomorphic(QuaternionGroup())
     152        True
     153        sage: all([groups.presentation.DiCyclic(i).as_permutation_group(
     154        ....: ).is_isomorphic(groups.permutation.DiCyclic(i)) for i in [5,8,12,2^5]])
     155        True
     156        sage: groups.presentation.DiCyclic(1)
     157        Traceback (most recent call last):
     158        ...
     159        ValueError: input integer must be greater than 1
     160    """
     161    n = Integer(n)
     162    if n < 2:
     163        raise ValueError('input integer must be greater than 1')
     164   
     165    F = FreeGroup(['a','b'])
     166    rls =  F([1])**(2*n), F([2,2])*F([-1])**n, F([-2,1,2,1])
     167    return FinitelyPresentedGroup(F, rls)
     168
     169def KleinFourPresentation():
     170    """
     171    Build the Klein group of order `4` as a finitely presented group.
     172
     173    OUTPUT:
     174
     175    Klein four group (`C_2 \\times C_2`) as a finitely presented group.
     176
     177    EXAMPLES::
     178
     179        sage: K = groups.presentation.KleinFour(); K
     180        Finitely presented group < a, b | a^2, b^2, a^-1*b^-1*a*b >
     181    """
     182    F = FreeGroup(['a','b'])
     183    rls = F([1])**2, F([2])**2, F([-1])*F([-2])*F([1])*F([2])
     184    return FinitelyPresentedGroup(F, rls)
  • sage/groups/groups_catalog.py

    diff --git a/sage/groups/groups_catalog.py b/sage/groups/groups_catalog.py
    a b  
    3737    - :func:`groups.matrix.GO <sage.groups.matrix_gps.orthogonal.GO>`
    3838    - :func:`groups.matrix.SO <sage.groups.matrix_gps.orthogonal.SO>`
    3939
     40- Finitely Presented Groups (``groups.presentation.<tab>``)
     41    - :func:`groups.presentation.Cyclic <sage.groups.finitely_presented_named.CyclicPresentation>`
     42    - :func:`groups.presentation.Dihedral <sage.groups.finitely_presented_named.DihedralPresentation>`
     43    - :func:`groups.presentation.DiCyclic <sage.groups.finitely_presented_named.DiCyclicPresentation>`
     44    - :func:`groups.presentation.KleinFour <sage.groups.finitely_presented_named.KleinFourPresentation>`
     45
    4046- Miscellaneous Groups (``groups.misc.<tab>``)
    4147"""
    4248
     
    6268from sage.groups.matrix_gps import catalog as matrix
    6369from sage.groups.perm_gps import permutation_groups_catalog as permutation
    6470from sage.groups.misc_gps import misc_groups_catalog as misc
    65 
     71from sage.groups import finitely_presented_catalog as presentation