Ticket #14813: trac_14813_fgabelian_fpgroups.patch

File trac_14813_fgabelian_fpgroups.patch, 6.9 KB (added by dshurbert, 8 years ago)

Replacement patch

  • sage/groups/finitely_presented_catalog.py

    # HG changeset patch
    # User Davis Shurbert <dshurbert@pugetsound.edu>
    # Date 1372123063 25200
    # Node ID a0be69370cc428f849bb77e19c42e7b9beb0684a
    # Parent  76327d6cefae5d7746b4edf0a877a40bb8e0eccb
    14813: Finitely generated abelian groups for the named fp group framework
    
    diff --git a/sage/groups/finitely_presented_catalog.py b/sage/groups/finitely_presented_catalog.py
    a b  
    1616from finitely_presented_named import DihedralPresentation as Dihedral
    1717from finitely_presented_named import CyclicPresentation as Cyclic
    1818from finitely_presented_named import DiCyclicPresentation as DiCyclic
     19from finitely_presented_named import FinitelyGeneratedAbelianPresentation as FGAbelian
    1920from finitely_presented_named import KleinFourPresentation as KleinFour
  • sage/groups/finitely_presented_named.py

    diff --git a/sage/groups/finitely_presented_named.py b/sage/groups/finitely_presented_named.py
    a b  
    1919- Dihedral group, `D_n` of order `2n` --
    2020  :func:`groups.presentation.Dihedral <sage.groups.finitely_presented_named.DihedralPresentation>`
    2121
     22- Finitely generated abelian group, `\ZZ_{n_1} \times \ZZ_{n_2} \times \cdots \times \ZZ_{n_k}` --
     23  :func:`groups.presentation.FGAbelian <sage.groups.finitely_presented_named.FinitelyGeneratedAbelianPresentation>` 
     24
    2225- Klein four group, `C_2 \times C_2` --
    2326  :func:`groups.presentation.KleinFour <sage.groups.finitely_presented_named.KleinFourPresentation>`
    2427
     
    4851from sage.groups.free_group import FreeGroup
    4952from sage.groups.finitely_presented import FinitelyPresentedGroup
    5053
     54from sage.matrix.constructor import diagonal_matrix
     55from sage.modules.fg_pid.fgp_module import FGP_Module
     56from sage.rings.integer_ring import ZZ
     57from sage.sets.set import Set
     58
    5159def CyclicPresentation(n):
    5260    r"""
    5361    Build cyclic group of order `n` as a finitely presented group.
     
    8290    rls = F([1])**n,
    8391    return FinitelyPresentedGroup( F, rls )
    8492
     93def FinitelyGeneratedAbelianPresentation(int_list):
     94    r"""
     95    Return canonical presentation of finitely generated abelian group.
     96
     97    INPUT:
     98
     99    - ``int_list`` -- List of integers defining the group to be returned, the defining list
     100      is reduced to the invariants of the input list before generating the corresponding
     101      group.
     102
     103    OUTPUT:
     104
     105    Finitely generated abelian group, `\ZZ_{n_1} \times \ZZ_{n_2} \times \cdots \times \ZZ_{n_k}`
     106    as a finite presentation, where `n_i` forms the invariants of the input list.
     107
     108    EXAMPLES::
     109
     110        sage: groups.presentation.FGAbelian([2,2])
     111        Finitely presented group < a, b | a^2, b^2, a^-1*b^-1*a*b >
     112        sage: groups.presentation.FGAbelian([2,3])
     113        Finitely presented group < a | a^6 >
     114        sage: groups.presentation.FGAbelian([2,4])
     115        Finitely presented group < a, b | a^2, b^4, a^-1*b^-1*a*b >
     116
     117    You can create free abelian groups::
     118
     119        sage: groups.presentation.FGAbelian([0])   
     120        Finitely presented group < a |  >
     121        sage: groups.presentation.FGAbelian([0,0])
     122        Finitely presented group < a, b | a^-1*b^-1*a*b >
     123        sage: groups.presentation.FGAbelian([0,0,0])
     124        Finitely presented group < a, b, c | a^-1*c^-1*a*c, a^-1*b^-1*a*b, c^-1*b^-1*c*b >
     125   
     126    And various infinite abelian groups::
     127
     128        sage: groups.presentation.FGAbelian([0,2])
     129        Finitely presented group < a, b | a^2, a^-1*b^-1*a*b >
     130        sage: groups.presentation.FGAbelian([0,2,2])
     131        Finitely presented group < a, b, c | a^2, b^2, a^-1*c^-1*a*c, a^-1*b^-1*a*b, c^-1*b^-1*c*b >
     132
     133    Outputs are reduced to minimal generators and relations::
     134
     135        sage: groups.presentation.FGAbelian([3,5,2,7,3])
     136        Finitely presented group < a, b | a^3, b^210, a^-1*b^-1*a*b >
     137        sage: groups.presentation.FGAbelian([3,210])
     138        Finitely presented group < a, b | a^3, b^210, a^-1*b^-1*a*b >
     139
     140    The trivial group is an acceptable output::
     141
     142        sage: groups.presentation.FGAbelian([])
     143        Finitely presented group <  |  >
     144        sage: groups.presentation.FGAbelian([1])
     145        Finitely presented group <  |  >
     146        sage: groups.presentation.FGAbelian([1,1,1,1,1,1,1,1,1,1])
     147        Finitely presented group <  |  >
     148
     149    Input list must consist of positive integers::
     150
     151        sage: groups.presentation.FGAbelian([2,6,3,9,-4])
     152        Traceback (most recent call last):
     153        ...
     154        ValueError: input list must contain nonnegative entries
     155        sage: groups.presentation.FGAbelian([2,'a',4])   
     156        Traceback (most recent call last):
     157        ...
     158        TypeError: unable to convert x (=a) to an integer
     159
     160    TESTS::
     161
     162        sage: ag = groups.presentation.FGAbelian([2,2])
     163        sage: ag.as_permutation_group().is_isomorphic(groups.permutation.KleinFour())
     164        True
     165        sage: G = groups.presentation.FGAbelian([2,4,8])
     166        sage: C2 = CyclicPermutationGroup(2)
     167        sage: C4 = CyclicPermutationGroup(4)
     168        sage: C8 = CyclicPermutationGroup(8)
     169        sage: gg = (C2.direct_product(C4)[0]).direct_product(C8)[0]
     170        sage: gg.is_isomorphic(G.as_permutation_group())
     171        True
     172        sage: all([groups.presentation.FGAbelian([i]).as_permutation_group().is_isomorphic(groups.presentation.Cyclic(i).as_permutation_group()) for i in [2..35]])
     173        True
     174    """
     175    from sage.groups.free_group import _lexi_gen
     176    check_ls = [Integer(x) for x in int_list if Integer(x) >= 0]
     177    if len(check_ls) != len(int_list):
     178        raise ValueError('input list must contain nonnegative entries')
     179   
     180    col_sp = diagonal_matrix(int_list).column_space()
     181    invariants = FGP_Module(ZZ**(len(int_list)), col_sp).invariants()
     182    name_gen = _lexi_gen()
     183    F = FreeGroup([name_gen.next() for i in invariants])
     184    ret_rls = [F([i+1])**invariants[i] for i in range(len(invariants)) if invariants[i]!=0]
     185   
     186    # Build commutator relations
     187    gen_pairs = list(Set(F.gens()).subsets(2))
     188    ret_rls = ret_rls + [x[0]**(-1)*x[1]**(-1)*x[0]*x[1] for x in gen_pairs]
     189    return FinitelyPresentedGroup(F, tuple(ret_rls))
     190
    85191def DihedralPresentation(n):
    86192    r"""
    87193    Build the Dihedral group of order `2n` as a finitely presented group.
  • sage/groups/groups_catalog.py

    diff --git a/sage/groups/groups_catalog.py b/sage/groups/groups_catalog.py
    a b  
    4444  - :func:`groups.presentation.Cyclic <sage.groups.finitely_presented_named.CyclicPresentation>`
    4545  - :func:`groups.presentation.Dihedral <sage.groups.finitely_presented_named.DihedralPresentation>`
    4646  - :func:`groups.presentation.DiCyclic <sage.groups.finitely_presented_named.DiCyclicPresentation>`
     47  - :func:`groups.presentation.FGAbelian <sage.groups.finitely_presented_named.FinitelyGeneratedAbelianPresentation>`
    4748  - :func:`groups.presentation.KleinFour <sage.groups.finitely_presented_named.KleinFourPresentation>`
    4849
    4950- Miscellaneous Groups (``groups.misc.<tab>``)