K i pddlmZddlmZddlmZej ZdZdZdZ dZ dZ d Z d Z d Zy ) ) DirectProduct)PermutationGroup) Permutationcg}d}d}|D]&}||z }||z}|jt|(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 rT)append CyclicGroupr _is_abelian_degree_order) cyclic_ordersgroupsdegreeordersizeGs f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/combinatorics/named_groups.py AbelianGrouprslBF F E)$   k$'() vAAMAIAH Hc|dvrttdggStt|}|d|d|dc|d<|d<|d<|}|dzr)ttd|}|j d|}n:ttd|}|j d|j dd|}||g}||k(r|dd}t|Dcgc] }t |c}d}t|||d|_|Scc}w) 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" )rrrrNF)dupsT) rrlistrangerinsert_af_new set_alternating_group_properties_is_alt)nagen1gen2gensrs rAlternatingGroupr$8sL F{aS!1 233 U1XAtQqT1Q4AaD!A$! D1u q!    q!    A $>> 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 rrTr) rrrrrr r)r*r r+r r,)rr genrs rr r so< U1a[AHHQK !*C#AAMAOANAIAAH1fAN Hrc|dk(rttddggS|dk(r/ttgdtgdtgdgSttd|}|j dt |}tt|}|j t |}t||g}||dz zdk(rd|_nd|_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 rrr)rrr)rr1rr)r1rrrTF)rrrrrrreverser)r,r r*r r+r )rr r!r"rs r DihedralGroupr3sR AvaV!4 566Av\!:<(+l*C!EF F U1a[AHHQK 1:D U1XAIIK 1:D$&AAaCyA~ANAMANAIAsAH Hrc||dk(rttdgg}n|dk(rttddgg}nnttd|}|j dt |}tt|}|d|dc|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 rrrT)rrrrrrset_symmetric_group_properties_is_sym)rrr r!r"s rSymmetricGroupr7sN Av k1#./ 0 a k1a&12 3 q!   qz qNqT1Q4 !adqz dD\ *"1a+AI Hrc|dkrd|_d|_nd|_d|_|dkrd|_nd|_||_d|_|dv|_y)z+Set known properties of a symmetric group. r1TFr')rr1Nr(r-s rr5r51sT1u  1uAIA6kANrcPddlm}|dkr tdt||S)zReturn a group of Rubik's cube generators >>> from sympy.combinatorics.named_groups import RubikGroup >>> RubikGroup(2).is_group True r)rubikrz(Invalid cube. n has to be greater than 1)sympy.combinatorics.generatorsr: ValueErrorr)rr:s r RubikGroupr=Bs)5AvCDD E!H %%rN)$sympy.combinatorics.group_constructsrsympy.combinatorics.perm_groupsr sympy.combinatorics.permutationsrrrr$rr r3r7r5r=rrrBsG><8   - `< ~"* ZA H5 p#" &r