§
    OŠtjº   ã                   óh   — d dl mZ d dlmZ d dlmZ ej        Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ ZdS )é    )ÚDirectProduct)ÚPermutationGroup)ÚPermutationc                  ó°   — g }d}d}| D ].}||z  }||z  }|                      t          |¦  «        ¦  «         Œ/t          |Ž }d|_        ||_        ||_        |S )a°  
    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         ú^/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/combinatorics/named_groups.pyÚAbelianGroupr      sv   € ðB €FØ€FØ€EØð )ð )ˆØ�$‰ˆØ�‰ˆØ�Š•k $Ñ'Ô'Ñ(Ô(Ð(Ð(Ý�vÐ€AØ€A„MØ€A„IØ€A„Hà€Hó    c                 ó`  — | dv rt          t          dg¦  «        g¦  «        S t          t          | ¦  «        ¦  «        }|d         |d         |d         c|d<   |d<   |d<   |}| dz  r5t          t          d| ¦  «        ¦  «        }|                     d¦  «         |}nJt          t          d| ¦  «        ¦  «        }|                     d¦  «         |                     dd¦  «         |}||g}||k    r
|dd…         }t          d„ |D ¦   «         d¬¦  «        }t          || | ¦  «         d	|_        |S )
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   Nc                 ó,   — g | ]}t          |¦  «        ‘ŒS © )Ú_af_new)Ú.0Úas     r   ú
<listcomp>z$AlternatingGroup.<locals>.<listcomp>p   s   € Ð3Ð3Ð3¨�' !™*œ*Ð3Ð3Ð3r   F)ÚdupsT)r   r   ÚlistÚranger   ÚinsertÚ set_alternating_group_propertiesÚ_is_alt)Únr   Úgen1Úgen2Úgensr   s         r   ÚAlternatingGroupr(   8   s6  € ðL 	ˆF€{€{Ý¥¨a¨SÑ!1Ô!1Ð 2Ñ3Ô3Ð3å�U�1‰XŒX‰Œ€AØ˜”t˜Q˜qœT 1 Q¤4Ð€A€a�Dˆ!ˆA‰$��!‘Ø€DØˆ1�uð Ý•�q˜!‘”ÑÔˆØ	�Š�‰ŒˆØˆˆå•�q˜!‘”ÑÔˆØ	�Š�‰ŒˆØ	�Š��A‰ŒˆØˆØ�$ˆ<€DØˆt‚|€|Ø�B�Q�BŒxˆÝÐ3Ð3¨dÐ3Ñ3Ô3¸%Ð@Ñ@Ô@€Aå$ Q¨¨1Ñ-Ô-Ð-Ø€A„IØ€Hr   c                 ó    — |dk     rd| _         d| _        nd| _         d| _        |dk     rd| _        nd| _        || _        d| _        d| _        dS )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   s\   € àˆ1‚u€uØˆŒØˆŒˆàˆŒØˆŒØˆ1‚u€uØˆŒˆàˆŒØ€A„IØ€AÔØ€A„N€N€Nr   c                 ó  — t          t          d| ¦  «        ¦  «        }|                     d¦  «         t          |¦  «        }t	          |g¦  «        }d|_        d|_        d|_        | |_        d|_	        | |_
        | dk    |_        |S )a»  
    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   r0   )r$   r   Úgenr   s       r   r	   r	   ˆ   s}   € õ< 	�U�1�a‰[Œ[ÑÔ€AØ‡H‚HˆQ�K„K€KÝ
�!‰*Œ*€CÝ˜#˜ÑÔ€Aà€A„MØ€A„OØ€A„NØ€A„IØ€AÔØ€A„HØ˜1’f€A„NØ€Hr   c                 óŒ  — | dk    rt          t          ddg¦  «        g¦  «        S | dk    r?t          t          g d¢¦  «        t          g d¢¦  «        t          g d¢¦  «        g¦  «        S t          t          d| ¦  «        ¦  «        }|                     d¦  «         t          |¦  «        }t          t          | ¦  «        ¦  «        }|                     ¦   «          t          |¦  «        }t          ||g¦  «        }| | dz
  z  dk    rd|_        nd|_        d|_        d|_	        d|_
        | |_        d|_        d| z  |_        |S )	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   r5   r   r   )r5   r   r   r   TF)r   r   r   r    r   r   Úreverser-   r0   r
   r.   r   r/   r   )r$   r   r%   r&   r   s        r   ÚDihedralGroupr7   µ   s:  € ðR 	ˆA‚v€vÝ¥¨a°¨VÑ!4Ô!4Ð 5Ñ6Ô6Ð6ØˆA‚v€vÝ¥¨\¨\¨\Ñ!:Ô!:Ý˜<˜<˜<Ñ(Ô(­+°l°l°lÑ*CÔ*Cð!Eñ Fô Fð 	Fõ 	�U�1�a‰[Œ[ÑÔ€AØ‡H‚HˆQ�K„K€KÝ�1‰:Œ:€DÝ�U�1‰XŒX‰Œ€AØ‡I‚I�K„K€KÝ�1‰:Œ:€DÝ˜$ ˜Ñ&Ô&€AàˆAˆa‰C�y�A‚~€~ØˆŒˆàˆŒØ€A„NØ€A„MØ€A„NØ€A„IØ€AÔØ�‰s€A„HØ€Hr   c                 óô  — | dk    rt          t          dg¦  «        g¦  «        }nº| dk    r t          t          ddg¦  «        g¦  «        }n”t          t          d| ¦  «        ¦  «        }|                     d¦  «         t          |¦  «        }t          t          | ¦  «        ¦  «        }|d         |d         c|d<   |d<   t          |¦  «        }t          ||g¦  «        }t          || | ¦  «         d|_        |S )aL  
    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   ÚSymmetricGroupr;   ù   sæ   € ðN 	ˆA‚v€vÝ�k¨1¨#Ñ.Ô.Ð/Ñ0Ô0ˆˆØ	
ˆaŠˆÝ�k¨1¨a¨&Ñ1Ô1Ð2Ñ3Ô3ˆˆå•�q˜!‘”ÑÔˆØ	�Š�‰ŒˆÝ�q‰zŒzˆÝ•�q‘”‰NŒNˆØ�q”T˜1˜Qœ4ˆ
ˆˆ!‰ˆa�‰dÝ�q‰zŒzˆÝ˜d D˜\Ñ*Ô*ˆÝ" 1 a¨Ñ+Ô+Ð+Ø€A„IØ€Hr   c                 ó¤   — |dk     rd| _         d| _        nd| _         d| _        |dk     rd| _        nd| _        || _        d| _        |dv | _        dS )z+Set known properties of a symmetric group. r5   TFr+   )r   r5   Nr,   r1   s      r   r9   r9   1  s`   € àˆ1‚u€uØˆŒØˆŒˆàˆŒØˆŒØˆ1‚u€uØˆŒˆàˆŒØ€A„IØ€AÔØ˜6�k€A„N€N€Nr   c                 óh   — ddl m} | dk    rt          d¦  «        ‚t           || ¦  «        ¦  «        S )z—Return 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   Ú
RubikGrouprA   B  sD   € ð 5Ð4Ð4Ð4Ð4Ð4ØˆA‚v€vÝÐCÑDÔDÐDÝ˜E˜E !™HœHÑ%Ô%Ð%r   N)Ú$sympy.combinatorics.group_constructsr   Úsympy.combinatorics.perm_groupsr   Ú sympy.combinatorics.permutationsr   r   r   r(   r"   r	   r7   r;   r9   rA   r   r   r   ú<module>rE      sÍ   ðØ >Ð >Ð >Ð >Ð >Ð >Ø <Ð <Ð <Ð <Ð <Ð <Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8à
Ô
€ð-ð -ð -ð`<ð <ð <ð~ð ð ð"*ð *ð *ðZAð Að AðH5ð 5ð 5ðp#ð #ð #ð"
&ð 
&ð 
&ð 
&ð 
&r   