Ticket #14791: trac_14791_named_fpgroups.patch

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

Patch

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

    # HG changeset patch
    # User Davis Shurbert <dshurbert@pugetsound.edu>
    # Date 1370586997 25200
    # Node ID dd54a38419e6bfd5db4dfbf440a72b43cb5792f5
    # Parent  85611cde252dfb0f7c07abe2764ac495c66490ee
    imported patch to_presentation
    
    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
  • 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>`.
     8
     9Groups available as finite presentations:   
     10
     11-- CyclicGroup, $C_n$ of order $n$
     12    - :func:`groups.presentation.Cyclic <sage.groups.finitely_presented_named.CyclicPresentation>`
     13
     14-- DiCyclicGroup, nonabelian groups of order $4n$ with a unique element of order 2
     15    - :func:`groups.presentation.DiCyclic <sage.groups.finitely_presented_named.DiCyclicPresentation>`
     16
     17-- DihedralGroup, $D_n$ of order $2n$
     18    - :func:`groups.presentation.Dihedral <sage.groups.finitely_presented_named.DihedralPresentation>`
     19
     20-- KleinFourGroup, `C_2 \\times C_2`
     21    - :func:`groups.presentation.KleinFour <sage.groups.finitely_presented_named.KleinFourPresentation>`
     22
     23EXAMPLES::
     24
     25    sage: groups.presentation.Cyclic(4)
     26    Finitely presented group < a | a^4 >
     27
     28You can also import the desired functions.::
     29
     30    sage: from sage.groups.finitely_presented_named import CyclicPresentation
     31    sage: CyclicPresentation(4)
     32    Finitely presented group < a | a^4 >
     33
     34"""
     35from sage.rings.all      import Integer
     36from sage.groups.free_group import FreeGroup
     37from sage.groups.finitely_presented import FinitelyPresentedGroup
     38
     39def CyclicPresentation(n):
     40    """
     41    Builds cyclic group of order `n` as a finitely presented group.
     42
     43    INPUT:
     44
     45    - ``n`` -- The order of the cyclic presentation to be returned.
     46
     47    OUTPUT:
     48
     49    The cyclic group of order `n` as finite presentation.
     50
     51    EXAMPLES::
     52
     53        sage: groups.presentation.Cyclic(10)
     54        Finitely presented group < a | a^10 >
     55        sage: n = 8
     56        sage: C = groups.presentation.Cyclic(n)
     57        sage: C.as_permutation_group().is_isomorphic(CyclicPermutationGroup(n))
     58        True
     59
     60    TESTS::
     61
     62        sage: groups.presentation.Cyclic(0)
     63        Traceback (most recent call last):
     64        ...
     65        ValueError: Finitely presented group order must be positive
     66
     67    """
     68    n = Integer(n)
     69    if n < 1:
     70        raise ValueError('Finitely presented group order must be positive')
     71    F = FreeGroup( 'a' )
     72    rls = F([1])**n,
     73    return FinitelyPresentedGroup( F, rls )
     74
     75def DihedralPresentation(n):
     76    """
     77    Builds the Dihedral group of order $2n$ as a finitely presented group.
     78   
     79    INPUT:
     80
     81    - ``n`` -- The size of the set that `D_n` is acting on.
     82
     83    OUTPUT:
     84
     85    Dihedral group of order `2n`.
     86 
     87    EXAMPLES::
     88
     89        sage: D = groups.presentation.Dihedral(7); D
     90        Finitely presented group < a, b | a^7, b^2, a*b*a*b >
     91        sage: D.as_permutation_group().is_isomorphic(DihedralGroup(7))
     92        True
     93
     94
     95    TESTS::
     96
     97        sage: n = 9
     98        sage: D = groups.presentation.Dihedral(n)
     99        sage: D.ngens() == 2
     100        True
     101        sage: groups.presentation.Dihedral(0)
     102        Traceback (most recent call last):
     103        ...
     104        ValueError: Finitely presented group order must be positive
     105
     106    """
     107    n = Integer( n )
     108    if n < 1:
     109        raise ValueError('Finitely presented group order must be positive')
     110    F = FreeGroup([ 'a', 'b' ])
     111    rls = F([1])**n, F([2])**2, (F([1])*F([2]))**2
     112    return FinitelyPresentedGroup( F, rls )
     113
     114def DiCyclicPresentation(n):
     115    """
     116    Builds the DiCyclic group of order $4n$ as a finitely presented group.
     117   
     118    INPUT:
     119
     120    - ``n`` -- Determines the order of the group (`4n`).
     121   
     122    OUTPUT:
     123
     124    DiCyclic group of order `4n`.
     125
     126    EXAMPLES::
     127       
     128        sage: D = groups.presentation.DiCyclic(9); D
     129        Finitely presented group < a, b | a^18, b^2*a^-9, b^-1*a*b*a >
     130        sage: D.as_permutation_group().is_isomorphic(groups.permutation.DiCyclic(9))
     131        True
     132
     133    TESTS::
     134
     135        sage: groups.presentation.DiCyclic(0)
     136        Traceback (most recent call last):
     137        ...
     138        ValueError: Finitely presented group order must be positive
     139
     140    """
     141    n = Integer(n)
     142    if n < 1:
     143        raise ValueError('Finitely presented group order must be positive')
     144    F = FreeGroup(['a','b'])
     145    rls = F([1])**(2*n), F([2,2])*F([-1])**n, F([-2,1,2,1])
     146    return FinitelyPresentedGroup(F, rls)
     147
     148def KleinFourPresentation():
     149    """
     150    Builds the Klein group of order `4` as a finitely presented group.
     151
     152    OUTPUT:
     153
     154    Klein four group (`C_2 \\times C_2`) as a finitely presented group.
     155
     156    EXAMPLES::
     157
     158        sage: K = groups.presentation.KleinFour(); K
     159        Finitely presented group < a, b | a^2, b^2, a^-1*b^-1*a*b >
     160
     161    """
     162    F = FreeGroup(['a','b'])
     163    rls = F([1])**2, F([2])**2, F([-1])*F([-2])*F([1])*F([2])
     164    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 matrix_groups_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