Ë
    7^(h†+  ã                   ód   — d dl mZ d dlmZ ej                  Zd„ Zdd„Zd„ Zdd„Zdd„Z	d	„ Z
d
„ Zy)é    )ÚPermutation)Ú_distribute_gens_by_basec                 ó|   — | D �ch c]  }t        |«      ’Œ c}|D �ch c]  }t        |«      ’Œ c}k(  S c c}w c c}w )ao  
    Compare two lists of permutations as sets.

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

    This is used for testing purposes. Since the array form of a
    permutation is currently a list, Permutation is not hashable
    and cannot be put into a set.

    Examples
    ========

    >>> from sympy.combinatorics.permutations import Permutation
    >>> from sympy.combinatorics.testutil import _cmp_perm_lists
    >>> a = Permutation([0, 2, 3, 4, 1])
    >>> b = Permutation([1, 2, 0, 4, 3])
    >>> c = Permutation([3, 4, 0, 1, 2])
    >>> ls1 = [a, b, c]
    >>> ls2 = [b, c, a]
    >>> _cmp_perm_lists(ls1, ls2)
    True

    )Útuple)ÚfirstÚsecondÚas      úZ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/combinatorics/testutil.pyÚ_cmp_perm_listsr      s8   € ð2 $Ö$˜ŒE�!�HÒ$Ø$Ö%˜ŒE�!�HÒ%ñ&ð &ùÒ$ùÚ%s   …4�9c                 ó  ‡	‡
— ddl m} 	 ddlmŠ	 t	        |d«      r¢t        | j                  d¬«      «      }|j                  D �cg c]  }|j                  ‘Œ c}Š
ˆ	ˆ
fd„}g }|s6|D ]/  } ||«      sŒ|j                  t        j                  |«      «       Œ1 |S |D ]  } ||«      sŒ|j                  |«       Œ |S t	        |d«      rt        |  ||«      |«      S t	        |d	«      rt        |  ||g«      |«      S y c c}w )
Nr   ©ÚPermutationGroup)Ú_af_commutes_withÚ
generatorsT©Úafc                 ó0   •‡ — t        ˆˆ fd„‰D «       «      S )Nc              3   ó0   •K  — | ]  } ‰‰|«      –— Œ y ­w©N© )Ú.0Úgenr   Úxs     €€r
   ú	<genexpr>z<_naive_list_centralizer.<locals>.<lambda>.<locals>.<genexpr>C   s   øè ø€ Ò*UÈÑ+<¸QÀ×+DÑ*Uùs   ƒ)Úall)r   r   Úgenss   `€€r
   ú<lambda>z)_naive_list_centralizer.<locals>.<lambda>C   s   ù€ ¤sÔ*UÐPTÔ*UÓ'U€ ó    ÚgetitemÚ
array_form)Úsympy.combinatorics.perm_groupsr   Ú sympy.combinatorics.permutationsr   ÚhasattrÚlistÚgenerate_diminor   Ú_array_formÚappendr   Ú_af_newÚ_naive_list_centralizer)ÚselfÚotherr   r   Úelementsr   Úcommutes_with_gensÚcentralizer_listÚelementr   r   s            @@r
   r)   r)   $   s  ù€ Ý@ðõ2 CÜˆu�lÔ#Ü˜×,Ñ,°Ð,Ó5Ó6ˆØ',×'7Ñ'7Ö8 !�—“Ò8ˆÜUÐØÐÙØ#ò J�Ù% gÕ.Ø$×+Ñ+¬K×,?Ñ,?ÀÓ,HÕIðJð  Ðð $ò 5�Ù% gÕ.Ø$×+Ñ+¨GÕ4ð5ð  ÐÜ	�˜	Ô	"Ü& tÑ-=¸eÓ-DÀbÓIÐIÜ	�˜Ô	%Ü& tÑ-=¸u¸gÓ-FÈÓKÐKð 
&ùò 9s   ÁC>c                 ó
  — ddl m} t        ||«      }| }t        t	        |«      «      D ]D  } |||   «      }|j                  «       |j                  «       k7  r y|j                  ||   «      }ŒF |j                  «       dk7  ryy)aÏ  
    Verify the correctness of a base and strong generating set.

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

    This is a naive implementation using the definition of a base and a strong
    generating set relative to it. There are other procedures for
    verifying a base and strong generating set, but this one will
    serve for more robust testing.

    Examples
    ========

    >>> from sympy.combinatorics.named_groups import AlternatingGroup
    >>> from sympy.combinatorics.testutil import _verify_bsgs
    >>> A = AlternatingGroup(4)
    >>> A.schreier_sims()
    >>> _verify_bsgs(A, A.base, A.strong_gens)
    True

    See Also
    ========

    sympy.combinatorics.perm_groups.PermutationGroup.schreier_sims

    r   r   Fé   T)r!   r   r   ÚrangeÚlenÚorderÚ
stabilizer)ÚgroupÚbaser   r   Ústrong_gens_distrÚcurrent_stabilizerÚiÚ	candidates           r
   Ú_verify_bsgsr<   T   sŽ   € õ8 AÜ0°°tÓ<ÐØÐÜ”3�t“9Óò DˆÙ$Ð%6°qÑ%9Ó:ˆ	Ø×#Ñ#Ó%¨¯©Ó):Ò:ÙØ/×:Ñ:¸4À¹7ÓCÑð	Dð
 ×ÑÓ! QÒ&ØØr   Nc                 ó’   — |€| j                  |«      }t        |j                  d¬«      «      }t        | |d¬«      }t	        ||«      S )a3  
    Verify the centralizer of a group/set/element inside another group.

    This is used for testing ``.centralizer()`` from
    ``sympy.combinatorics.perm_groups``

    Examples
    ========

    >>> from sympy.combinatorics.named_groups import (SymmetricGroup,
    ... AlternatingGroup)
    >>> from sympy.combinatorics.perm_groups import PermutationGroup
    >>> from sympy.combinatorics.permutations import Permutation
    >>> from sympy.combinatorics.testutil import _verify_centralizer
    >>> S = SymmetricGroup(5)
    >>> A = AlternatingGroup(5)
    >>> centr = PermutationGroup([Permutation([0, 1, 2, 3, 4])])
    >>> _verify_centralizer(S, A, centr)
    True

    See Also
    ========

    _naive_list_centralizer,
    sympy.combinatorics.perm_groups.PermutationGroup.centralizer,
    _cmp_perm_lists

    Tr   )Úcentralizerr$   r%   r)   r   )r6   ÚargÚcentrÚ
centr_listÚcentr_list_naives        r
   Ú_verify_centralizerrC   }   sN   € ð: €}Ø×!Ñ! #Ó&ˆÜ�e×+Ñ+¨tÐ+Ó4Ó5€JÜ.¨u°c¸dÔCÐÜ˜:Ð'7Ó8Ð8r   c                 ó\  ‡— ddl m} 	 |€| j                  |«      }t        «       }t	        |d«      r|j
                  }nt	        |d«      r|}nt	        |d«      r|g}| j                  «       D ]  Š|j                  ˆfd„D «       «       Œ  |t        |«      «      }|j                  |«      S )Nr   r   r   Ú__getitem__r    c              3   ó(   •K  — | ]	  }|‰z  –— Œ y ­wr   r   )r   r   Úels     €r
   r   z)_verify_normal_closure.<locals>.<genexpr>Ä   s   øè ø€ Ò9 s˜# �(Ñ9ùs   ƒ)
r!   r   Únormal_closureÚsetr#   r   r%   Úupdater$   Úis_subgroup)r6   r?   Úclosurer   Ú
conjugatesÚ
subgr_gensÚnaive_closurerG   s          @r
   Ú_verify_normal_closurerP   ¡   s¨   ø€ Ý@ðð. €Ø×&Ñ& sÓ+ˆÜ“€JÜˆs�LÔ!Ø—^‘^‰
Ü	��mÔ	$Ø‰
Ü	��lÔ	#Ø�Uˆ
Ø×#Ñ#Ó%ò :ˆØ×ÑÓ9¨jÔ9Õ9ð:á$¤T¨*Ó%5Ó6€MØ×Ñ˜}Ó-Ð-r   c           	      ón  — ddl m} ddlm}m} ddlm} g }t        t        |«      «      D ]%  }	||	   \  }
}}}|j                  |
|g g|z  |f«       Œ'  ||Ž \  }}} ||||dz
  «      }t        |t        «      r	d}|g}|g}nt        |«      }g }t        |«      D ]$  }	|j                   |||	   ||	   |dz
  «      «       Œ&  ||«      } ||D �cg c]  }t        |«      ‘Œ c}«      }t        |j                  d¬«      «      }| j                   } t#        «       }|j                  d¬«      D ]5  } || |«      }|D ]%  }t%         |||«      «      }|j'                  |«       Œ' Œ7 t        |«      }|j)                  «        d	|z  }|D ]  }|d
d |d
d k(  r|d   |d   k7  r y|}Œ t        |d   «      S c c}w )au  
    Canonicalize tensor formed by tensors of the different types.

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

    sym_i symmetry under exchange of two component tensors of type `i`
          None  no symmetry
          0     commuting
          1     anticommuting

    Parameters
    ==========

    g : Permutation representing the tensor.
    dummies : List of dummy indices.
    msym : Symmetry of the metric.
    v : A list of (base_i, gens_i, n_i, sym_i) for tensors of type `i`.
        base_i, gens_i BSGS for tensors of this type
        n_i  number of tensors of type `i`

    Returns
    =======

    Returns 0 if the tensor is zero, else returns the array form of
    the permutation representing the canonical form of the tensor.

    Examples
    ========

    >>> from sympy.combinatorics.testutil import canonicalize_naive
    >>> from sympy.combinatorics.tensor_can import get_symmetric_group_sgs
    >>> from sympy.combinatorics import Permutation
    >>> g = Permutation([1, 3, 2, 0, 4, 5])
    >>> base2, gens2 = get_symmetric_group_sgs(2)
    >>> canonicalize_naive(g, [2, 3], 0, (base2, gens2, 2, 0))
    [0, 2, 1, 3, 4, 5]
    r   r   )Úgens_productsÚ	dummy_sgs)Ú_af_rmulé   r1   Tr   )r   Néþÿÿÿéÿÿÿÿ)r!   r   Úsympy.combinatorics.tensor_canrR   rS   r"   rT   r2   r3   r'   Ú
isinstanceÚintÚextendr   r$   Úgenerater    rI   r   ÚaddÚsort)ÚgÚdummiesÚsymÚvr   rR   rS   rT   Úv1r:   Úbase_iÚgens_iÚn_iÚsym_iÚsizeÚsbaseÚsgensÚdgensÚ	num_typesÚSr   ÚDÚdlistÚstÚsÚhÚdÚqr	   Úprevs                                 r
   Úcanonicalize_naiverv   É   sá  € õN AßGÝ9Ø	€BÜ”3�q“6‹]ò 5ˆØ%& q¡TÑ"ˆ�˜˜UØ
�	‰	�6˜6 B 4¨¡8¨UÐ3Õ4ð5ñ '¨Ð+Ñ€Dˆ%�Ù�g˜s D¨¡FÓ+€EÜ�#”sÔØˆ	Ø�)ˆØˆe‰ä˜“Hˆ	Ø€EÜ�9Óò >ˆØ�‰‘Y˜w q™z¨3¨q©6°4¸!±8Ó<Õ=ð>á˜Ó€AÙ°%Ö8¨Qœ+ a�.Ò8Ó9€AÜ�—‘˜t�Ó$Ó%€EØ	�‰€AÜ	‹€BØ�Z‰Z˜4ˆZÓ ò ˆÙ�Q˜‹NˆØò 	ˆAÜ‘h˜q !“nÓ%ˆAØ�F‰F�1�Iñ	ðô
 	ˆR‹€AØ‡F�F„HØ�‰9€DØò ˆØˆSˆbˆ6�T˜#˜2�YÒØ�‰u˜˜R™Ò ÙØ‰ð	ô
 ��!‘‹:Ðùò# 9s   ÃF2c                 óÔ  — ddl m} ddlm}m} t        | j                  «       «      }|j                  d„ d¬«       |D �cg c]  }|d   ‘Œ	 }} ||«      }d}|D ]  \  }}	|t        |	«      z  }Œ |D �
cg c]  }
g ‘Œ }}
d}
|D ]N  \  }}	|	D ]D  }||   ||   k  sŒ|||      j                  |
«       |||      j                  |
dz   «       |
dz  }
ŒF ŒP g }|D ]  }|j                  |«       Œ t        |«      |k(  sJ ‚|||dz   gz  }|dz   }t        |«      t        t        |«      «      k(  sJ ‚t        |«      }dgt        |d   «      dz   z  }|D ]  }	|t        |	«      xx   dz  cc<   Œ g }t        t        |«      «      D ]*  }
||
   }|sŒ ||
«      \  }}|j                  |||df«       Œ, |j                  «        t        t        |«      «      } |||dg|¢­Ž }|S c c}w c c}
w )	a  
    Return a certificate for the graph

    Parameters
    ==========

    gr : adjacency list

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

    The graph is assumed to be unoriented and without
    external lines.

    Associate to each vertex of the graph a symmetric tensor with
    number of indices equal to the degree of the vertex; indices
    are contracted when they correspond to the same line of the graph.
    The canonical form of the tensor gives a certificate for the graph.

    This is not an efficient algorithm to get the certificate of a graph.

    Examples
    ========

    >>> from sympy.combinatorics.testutil import graph_certificate
    >>> gr1 = {0:[1, 2, 3, 5], 1:[0, 2, 4], 2:[0, 1, 3, 4], 3:[0, 2, 4], 4:[1, 2, 3, 5], 5:[0, 4]}
    >>> gr2 = {0:[1, 5], 1:[0, 2, 3, 4], 2:[1, 3, 5], 3:[1, 2, 4, 5], 4:[1, 3, 5], 5:[0, 2, 3, 4]}
    >>> c1 = graph_certificate(gr1)
    >>> c2 = graph_certificate(gr2)
    >>> c1
    [0, 2, 4, 6, 1, 8, 10, 12, 3, 14, 16, 18, 5, 9, 15, 7, 11, 17, 13, 19, 20, 21]
    >>> c1 == c2
    True
    r   )Ú
_af_invert)Úget_symmetric_group_sgsÚcanonicalizec                 ó   — t        | d   «      S )Nr1   )r3   )r   s    r
   r   z#graph_certificate.<locals>.<lambda>=  s   € œS  1¡›Y€ r   T)ÚkeyÚreverser1   rU   )r"   rx   rX   ry   rz   r$   Úitemsr^   r3   r'   r[   Úsortedr2   r   r}   )Úgrrx   ry   rz   r~   r   ÚpvertÚnum_indicesrb   Úneighr:   ÚverticesÚv2r_   rh   ÚvlenÚnr7   r   r`   Úcans                        r
   Úgraph_certificater‰     s5  € õF <ßTÜ�—‘“Ó€EØ	‡J�JÑ&°€JÔ5Ø Ö!�aˆQˆq‹TÐ!€EÐ!Ù�uÓ€Eð €KØò "‰ˆˆ5Ø”s˜5“zÑ!‰ð"ð "Ö"�q’Ð"€HÐ"Ø	€AØò ‰ˆˆ5Øò 	ˆBØ�Q‰x˜% ™)Ó#Ø˜˜q™Ñ"×)Ñ)¨!Ô,Ø˜˜r™Ñ#×*Ñ*¨1¨Q©3Ô/Ø�Q‘‘ñ		ðð 	€AØò ˆØ	�‰��ðäˆq‹6�[Ò Ð Ð Øˆ+�{ Q‘Ð	'Ñ'€AØ˜‰?€DÜ�!‹9œœU 4›[Ó)Ò)Ð)Ð)Ü�A‹€AØˆ3”�H˜Q‘KÓ  Ñ"Ñ#€DØò ˆØŒS�‹ZÓ˜AÑÔðà
€AÜ”3�t“9Óò )ˆØ�‰GˆÚÙ0°Ó3‰JˆD�$Ø�H‰H�d˜D ! QÐ'Õ(ð	)ð
 ‡I�I„KÜ”5˜Ó%Ó&€GÙ
�q˜' 1Ð
) qÒ
)€CØ€JùòO "ùò #s   Á G Á4	G%)Fr   )Úsympy.combinatoricsr   Úsympy.combinatorics.utilr   Úrmulr   r)   r<   rC   rP   rv   r‰   r   r   r
   ú<module>r�      sA   ðÝ +Ý =à×Ñ€ò&ó:-Lò`&óR!9óH%.òPKó\Nr   