
    \h                      p    S SK Jr  S SKJr  S SKJr  \R                  rS rS rS r	S r
S rS	 rS
 rS rg)    )DirectProduct)PermutationGroup)Permutationc                      / nSnSnU  H%  nX$-  nX4-  nUR                  [        U5      5        M'     [        U6 nSUl        X%l        X5l        U$ )aX  
Returns the direct product of cyclic groups with the given orders.

Explanation
===========

According to the structure theorem for finite abelian groups ([1]),
every finite abelian group can be written as the direct product of
finitely many cyclic groups.

Examples
========

>>> from sympy.combinatorics.named_groups import AbelianGroup
>>> AbelianGroup(3, 4)
PermutationGroup([
        (6)(0 1 2),
        (3 4 5 6)])
>>> _.is_group
True

See Also
========

DirectProduct

References
==========

.. [1] https://groupprops.subwiki.org/wiki/Structure_theorem_for_finitely_generated_abelian_groups

r      T)appendCyclicGroupr   _is_abelian_degree_order)cyclic_ordersgroupsdegreeordersizeGs         X/var/www/auris/envauris/lib/python3.13/site-packages/sympy/combinatorics/named_groups.pyAbelianGroupr      s_    B FFEk$'(  	vAAMIHH    c                    U S;   a  [        [        S/5      /5      $ [        [        U 5      5      nUS   US   US   sUS'   US'   US'   UnU S-  (       a)  [        [        SU 5      5      nUR	                  S5        UnO:[        [        SU 5      5      nUR	                  S5        UR                  SS5        UnX#/nX#:X  a  USS n[        U Vs/ s H  n[        U5      PM     snSS9n[        XPU 5        SUl        U$ s  snf )	a  
Generates the alternating group on ``n`` elements as a permutation group.

Explanation
===========

For ``n > 2``, the generators taken are ``(0 1 2), (0 1 2 ... n-1)`` for
``n`` odd
and ``(0 1 2), (1 2 ... n-1)`` for ``n`` even (See [1], p.31, ex.6.9.).
After the group is generated, some of its basic properties are set.
The cases ``n = 1, 2`` are handled separately.

Examples
========

>>> from sympy.combinatorics.named_groups import AlternatingGroup
>>> G = AlternatingGroup(4)
>>> G.is_group
True
>>> a = list(G.generate_dimino())
>>> len(a)
12
>>> all(perm.is_even for perm in a)
True

See Also
========

SymmetricGroup, CyclicGroup, DihedralGroup

References
==========

.. [1] Armstrong, M. "Groups and Symmetry"

)r      r   r   r   NF)dupsT)	r   r   listranger   insert_af_new set_alternating_group_properties_is_alt)nagen1gen2gensr   s         r   AlternatingGroupr$   8   s    L 	F{aS!1 233U1XAtQqT1Q4AaD!A$!D1uq!	q!		A<D|BQxd3d'!*d3%@A$Q1-AIH	 4s   C?c                     US:  a  SU l         SU l        OSU l         SU l        US:  a  SU l        OSU l        X l        SU l        SU l        g)z.Set known properties of an alternating group.    TF   Nr
   _is_nilpotent_is_solvabler   _is_transitive_is_dihedralr   r   r   s      r   r   r   w   sN    1u1uIAANr   c                     [        [        SU 5      5      nUR                  S5        [        U5      n[	        U/5      nSUl        SUl        SUl        Xl        SUl	        Xl
        U S:H  Ul        U$ )ag  
Generates the cyclic group of order ``n`` as a permutation group.

Explanation
===========

The generator taken is the ``n``-cycle ``(0 1 2 ... n-1)``
(in cycle notation). After the group is generated, some of its basic
properties are set.

Examples
========

>>> from sympy.combinatorics.named_groups import CyclicGroup
>>> G = CyclicGroup(6)
>>> G.is_group
True
>>> G.order()
6
>>> list(G.generate_schreier_sims(af=True))
[[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 0], [2, 3, 4, 5, 0, 1],
[3, 4, 5, 0, 1, 2], [4, 5, 0, 1, 2, 3], [5, 0, 1, 2, 3, 4]]

See Also
========

SymmetricGroup, DihedralGroup, AlternatingGroup

r   r   Tr   )r   r   r   r   r   r
   r)   r*   r   r+   r   r,   )r   r    genr   s       r   r	   r	      sk    < 	U1a[AHHQK
!*C#AAMAOANIAH1fANHr   c                    U S:X  a  [        [        SS/5      /5      $ U S:X  a/  [        [        / SQ5      [        / SQ5      [        / SQ5      /5      $ [        [        SU 5      5      nUR	                  S5        [        U5      n[        [        U 5      5      nUR                  5         [        U5      n[        X#/5      nX S-
  -  S:X  a  SUl        OSUl        SUl        SUl	        SUl
        Xl        SUl        SU -  Ul        U$ )	a  
Generates the dihedral group `D_n` as a permutation group.

Explanation
===========

The dihedral group `D_n` is the group of symmetries of the regular
``n``-gon. The generators taken are the ``n``-cycle ``a = (0 1 2 ... n-1)``
(a rotation of the ``n``-gon) and ``b = (0 n-1)(1 n-2)...``
(a reflection of the ``n``-gon) in cycle rotation. It is easy to see that
these satisfy ``a**n = b**2 = 1`` and ``bab = ~a`` so they indeed generate
`D_n` (See [1]). After the group is generated, some of its basic properties
are set.

Examples
========

>>> from sympy.combinatorics.named_groups import DihedralGroup
>>> G = DihedralGroup(5)
>>> G.is_group
True
>>> a = list(G.generate_dimino())
>>> [perm.cyclic_form for perm in a]
[[], [[0, 1, 2, 3, 4]], [[0, 2, 4, 1, 3]],
[[0, 3, 1, 4, 2]], [[0, 4, 3, 2, 1]], [[0, 4], [1, 3]],
[[1, 4], [2, 3]], [[0, 1], [2, 4]], [[0, 2], [3, 4]],
[[0, 3], [1, 2]]]

See Also
========

SymmetricGroup, CyclicGroup, AlternatingGroup

References
==========

.. [1] https://en.wikipedia.org/wiki/Dihedral_group

r   r   r   )r   r      r   )r   r1   r   r   )r1   r   r   r   TF)r   r   r   r   r   r   reverser)   r,   r
   r*   r   r+   r   )r   r    r!   r"   r   s        r   DihedralGroupr3      s    R 	AvaV!4 566Av\!:<(+l*C!E F 	F 	U1a[AHHQK1:DU1XAIIK1:D$&AaCyA~ANAMANIAsAHHr   c                 |   U S:X  a  [        [        S/5      /5      nOU S:X  a  [        [        SS/5      /5      nOm[        [        SU 5      5      nUR	                  S5        [        U5      n[        [        U 5      5      nUS   US   sUS'   US'   [        U5      n[        X4/5      n[        XU 5        SUl        U$ )a  
Generates the symmetric group on ``n`` elements as a permutation group.

Explanation
===========

The generators taken are the ``n``-cycle
``(0 1 2 ... n-1)`` and the transposition ``(0 1)`` (in cycle notation).
(See [1]). After the group is generated, some of its basic properties
are set.

Examples
========

>>> from sympy.combinatorics.named_groups import SymmetricGroup
>>> G = SymmetricGroup(4)
>>> G.is_group
True
>>> G.order()
24
>>> list(G.generate_schreier_sims(af=True))
[[0, 1, 2, 3], [1, 2, 3, 0], [2, 3, 0, 1], [3, 1, 2, 0], [0, 2, 3, 1],
[1, 3, 0, 2], [2, 0, 1, 3], [3, 2, 0, 1], [0, 3, 1, 2], [1, 0, 2, 3],
[2, 1, 3, 0], [3, 0, 1, 2], [0, 1, 3, 2], [1, 2, 0, 3], [2, 3, 1, 0],
[3, 1, 0, 2], [0, 2, 1, 3], [1, 3, 2, 0], [2, 0, 3, 1], [3, 2, 1, 0],
[0, 3, 2, 1], [1, 0, 3, 2], [2, 1, 0, 3], [3, 0, 2, 1]]

See Also
========

CyclicGroup, DihedralGroup, AlternatingGroup

References
==========

.. [1] https://en.wikipedia.org/wiki/Symmetric_group#Generators_and_relations

r   r   r   T)r   r   r   r   r   r   set_symmetric_group_properties_is_sym)r   r   r    r!   r"   s        r   SymmetricGroupr7      s    N 	Avk1#./0	
ak1a&123q!	qzqNqT1Q4
!adqzd\*"1+AIHr   c                     US:  a  SU l         SU l        OSU l         SU l        US:  a  SU l        OSU l        X l        SU l        US;   U l        g)z+Set known properties of a symmetric group. r1   TFr'   )r   r1   Nr(   r-   s      r   r5   r5   1  sR    1u1uIA6kANr   c                 R    SSK Jn  U S::  a  [        S5      e[        U" U 5      5      $ )zReturn a group of Rubik's cube generators

>>> from sympy.combinatorics.named_groups import RubikGroup
>>> RubikGroup(2).is_group
True
r   )rubikr   z(Invalid cube. n has to be greater than 1)sympy.combinatorics.generatorsr:   
ValueErrorr   )r   r:   s     r   
RubikGroupr=   B  s)     5AvCDDE!H%%r   N)$sympy.combinatorics.group_constructsr   sympy.combinatorics.perm_groupsr    sympy.combinatorics.permutationsr   r   r   r$   r   r	   r3   r7   r5   r=    r   r   <module>rB      sG    > < 8


-`<~"*ZAH5p#"
&r   