+
    ‹°³j£º  ã                   ó„  € R t ^ RIHt ^ RIHt ^ RIHtHtHt ^ RI	H
t
 ^ RIHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt ]R%R l4       t]R%R l4       t ]R 4       t!R t" ! R R]4      t# ! R R]4      t$R%R lt%R t&R t'R%R lt(RR/R lt)R t*R t+R&R lt,R  t-R! t.R" t/R'R$ lt0]t1R## )(z.Finitely Presented Groups and its algorithms. )ÚS)Úsymbols)Ú	FreeGroupÚFreeGroupElementÚ
free_group)ÚRewritingSystem)Ú
CosetTableÚcoset_enumeration_rÚcoset_enumeration_c)ÚPermutationGroup)Úinvariant_factors)ÚMatrix)Úgcd)ÚDefaultPrinting)Úpublic)Úpollute)Úproductc                 óR   € \        W4      pV3\        VP                  4      ,           # ©N)ÚFpGroupÚtupleÚ_generators©Úfr_grpÚrelatorsÚ	_fp_groups   && Ú^/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sympy/combinatorics/fp_groups.pyÚfp_groupr      s$   € ä˜Ó)€IØˆ<œ% 	× 5Ñ 5Ó6Õ6Ð6ó    c                 ó2   € \        W4      pW"P                  3# r   )r   r   r   s   && r   Ú	xfp_groupr       s   € ä˜Ó)€IØ×,Ñ,Ð-Ð-r   c                 ó¢   € \        \        V4      p\        VP                   Uu. uF  q3P                  NK  	  upVP                  4       V# u upi r   )r   r   r   ÚnameÚ
generators)Úfr_grpmr   r   Úsyms   &&  r   Ú	vfp_groupr&   !   sB   € äœ Ó*€IÜ ×!2Ò!2Ó3Ñ!2˜#�XŒXÑ!2Ñ3°Y×5IÑ5IÔJØÐùò 4s   ¤Ac                ó   € V # )zParse the passed relators.© )Úrelss   &r   Ú_parse_relatorsr*   (   s   € à€Kr   c                   óT  a € ] tR t^2t o RtRtRtRtR tR t	R t
R tR t]R	 4       tR
 tR(R ltR)R ltR tR)R ltR*R ltR tR+R ltR tR tR*R ltR t]tR tR tR tR tR t R t!R t"R t#R t$]R  4       t%]R! 4       t&]R" 4       t']R# 4       t(]R$ 4       t)R% t*R& t+R't,V t-R# ),r   z¸
The FpGroup would take a FreeGroup and a list/tuple of relators, the
relators would be specified in such a way that each of them be equal to the
identity of the provided free group.

TFc                óö   € \        V4      pWn        W n        V P                  4       V n        \        R \        3RV /4      V n        RV n        RV n	        RV n
        RV n        \        V 4      V n        RV n        R# )ÚFpGroupElementÚgroupNF)r*   r   r   r   r#   Útyper-   ÚdtypeÚ_coset_tableÚ_is_standardizedÚ_orderÚ_centerr   Ú_rewriting_systemÚ_perm_isomorphism)Úselfr   r   s   &&&r   Ú__init__ÚFpGroup.__init__=   sx   € Ü" 8Ó,ˆØ ŒØ ŒØ×*Ñ*Ó,ˆŒÜÐ*¬^Ð,=ÀÈ¸ÓOˆŒ
ð !ˆÔð !&ˆÔàˆŒØˆŒä!0°Ó!6ˆÔØ!%ˆÔÙr   c                ó.   € V P                   P                  # r   )r   r#   ©r7   s   &r   r   ÚFpGroup._generatorsQ   s   € Ø�‰×)Ñ)Ð)r   c                ó:   € V P                   P                  4        R# )z5
Try to make the group's rewriting system confluent

N)r5   Úmake_confluentr;   s   &r   r>   ÚFpGroup.make_confluentT   s   € ð
 	×Ñ×-Ñ-Ô/Ùr   c                ó8   € V P                   P                  V4      # )z±
Return the reduced form of `word` in `self` according to the group's
rewriting system. If it's confluent, the reduced form is the unique normal
form of the word in the group.

)r5   Úreduce)r7   Úwords   &&r   rA   ÚFpGroup.reduce\   s   € ð ×%Ñ%×,Ñ,¨TÓ2Ð2r   c                ó    € V P                  WR,          ,          4      V P                  8X  d   R# V P                  P                  '       d   R# R# )zû
Compare `word1` and `word2` for equality in the group
using the group's rewriting system. If the system is
confluent, the returned answer is necessarily correct.
(If it is not, `False` could be returned in some cases
where in fact `word1 == word2`)

TFNéÿÿÿÿ)rA   Úidentityr5   Úis_confluent)r7   Úword1Úword2s   &&&r   ÚequalsÚFpGroup.equalse   s:   € ð �;‰;�u B�Y•Ó'¨4¯=©=Ô8ÙØ×#Ñ#×0×0Ð0ÙÙr   c                ó.   € V P                   P                  # r   )r   rF   r;   s   &r   rF   ÚFpGroup.identityt   s   € à�‰×'Ñ'Ð'r   c                ó   € WP                   9   # r   )r   )r7   Úgs   &&r   Ú__contains__ÚFpGroup.__contains__x   s   € Ø—O‘OÑ#Ð#r   Nc           	     óJ  a € \         ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       g   \        R4      h\         ;QJ d    V 3R lV 4       F  '       d   K   RM	  RM! V 3R lV 4       4      '       g   \        R4      hV'       d   \        S WRR7      w  rEpM\        S WR7      w  rEV'       d   \        V^ ,          P                  V4      pM\        \        R	4      ^ ,          . 4      pV'       d   ^ R
IHp WC! VS VP                  XRR7      3# V# )a!  
Return the subgroup generated by `gens` using the
Reidemeister-Schreier algorithm
homomorphism -- When set to True, return a dictionary containing the images
             of the presentation generators in the original group.

Examples
========

>>> from sympy.combinatorics.fp_groups import FpGroup
>>> from sympy.combinatorics import free_group
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x**3, y**5, (x*y)**2])
>>> H = [x*y, x**-1*y**-1*x*y*x]
>>> K, T = f.subgroup(H, homomorphism=True)
>>> T(K.generators)
[x*y, x**-1*y**2*x**-1]

c              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5ir   )Ú
isinstancer   )Ú.0rO   s   & r   Ú	<genexpr>Ú#FpGroup.subgroup.<locals>.<genexpr>�   s   é € ÐA¹D°q”:˜aÔ!1×2Ð2»Dùs   ‚FTz&Generators must be `FreeGroupElement`sc              3   óT   <"  € T F  qP                   SP                  8H  x € K  	  R # 5ir   )r.   r   )rU   rO   r7   s   & €r   rV   rW   ’   s   øé € Ð<±t°!—7‘7˜dŸo™oÖ-³tùs   ƒ%(z-Given generators are not members of the group)ÚCÚhomomorphism©rY   Ú ©rZ   ©Úcheck)	ÚallÚ
ValueErrorÚreidemeister_presentationr   r.   r   Ú!sympy.combinatorics.homomorphismsrZ   r#   )r7   ÚgensrY   rZ   rO   r)   Ú_genss   f&&&   r   ÚsubgroupÚFpGroup.subgroup{   sÖ   ø€ ÷* ‹sÑA¹DÓA�s�sŠsÑA¹DÓA×AÒAÜÐEÓFÐFß‹sÔ<±tÓ<�s�sŠsÔ<±tÓ<×<Ò<Ü Ð!PÓQÐQßÜ6°t¸TÐUYÔZ‰NˆA‘Uä/°°dÔ@‰GˆAßÜ˜˜!�Ÿ
™
 DÓ)‰Aäœ
 2› qÕ)¨2Ó.ˆAßÝFØ�l 1 d¨A¯L©L¸%ÀuÔMÐMÐMØˆr   c                óÊ   € V'       g   \         P                  pVR8X  d   \        WVWER7      pM\        WVWER7      pVP	                  4       '       d   VP                  4        V# )a  
Return an instance of ``coset table``, when Todd-Coxeter algorithm is
run over the ``self`` with ``H`` as subgroup, using ``strategy``
argument as strategy. The returned coset table is compressed but not
standardized.

An instance of `CosetTable` for `fp_grp` can be passed as the keyword
argument `draft` in which case the coset enumeration will start with
that instance and attempt to complete it.

When `incomplete` is `True` and the function is unable to complete for
some reason, the partially complete table will be returned.

Úrelator_based©Ú
max_cosetsÚdraftÚ
incomplete)r   Úcoset_table_max_limitr	   r
   Úis_completeÚcompress©r7   ÚHÚstrategyrk   rl   rm   rY   s   &&&&&& r   Úcoset_enumerationÚFpGroup.coset_enumeration¡   sY   € ÷  Ü#×9Ñ9ˆJØ�Ô&Ü# D¸
Ø:?ôX‰Aô $ D¸
Ø:?ôXˆAà�=‰=�?Š?Ø�J‰JŒLØˆr   c                óH   € V P                   P                  4        RV n        R# )zp
Standardized the coset table ``self`` and makes the internal variable
``_is_standardized`` equal to ``True``.

TN)r1   Ústandardizer2   r;   s   &r   Ústandardize_coset_tableÚFpGroup.standardize_coset_table½   s   € ð 	×Ñ×%Ñ%Ô'Ø $ˆÖr   c                ó~  € V'       g‡   V P                   e9   V P                  '       g   V P                  4        V P                   P                  # V P                  . W#WER7      pW`n         V P                  4        V P                   P                  # V P                  WVWER7      pVP                  4        VP                  # )z<
Return the mathematical coset table of ``self`` in ``H``.

rj   )r1   r2   rx   rt   Útablerw   rq   s   &&&&&& r   Úcoset_tableÚFpGroup.coset_tableÆ   s±   € ÷ Ø× Ñ Ò,Ø×,×,Ð,Ø×0Ñ0Ô2ð ×$Ñ$×*Ñ*Ð*ð	 ×*Ñ*¨2¨xØ27ð +ó P�à$%Ô!Ø×,Ñ,Ô.Ø×$Ñ$×*Ñ*Ð*à×&Ñ& q¸zØ27ð 'ó PˆAà�M‰MŒOØ—7‘7ˆNr   c           	     ó¤  € V P                   e   V P                   # V P                  e1   \        V P                  P                  4      V n         V P                   # \        V P                  4      ^ 8X  d,   V P
                  P                  4       V n         V P                   # \        V P                  4      ^8X  dW   \        \        V P                   Uu. uF  q"P                  ^ ,          ^,          NK  	  up4      4      V n         V P                   # V P                  4       '       d"   \        P                  V n         V P                   # V P                  4       w  r4V'       dM   \        VP                  4      pWPP                  W4R7      P                  4       ,          V n         V P                   # V P!                  . 4      V n         V P                   # u upi )ao  
Returns the order of the finitely presented group ``self``. It uses
the coset enumeration with identity group as subgroup, i.e ``H=[]``.

Examples
========

>>> from sympy.combinatorics import free_group
>>> from sympy.combinatorics.fp_groups import FpGroup
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x, y**2])
>>> f.order(strategy="coset_table_based")
2

r[   )r3   r1   Úlenr{   r   r   Úorderr#   Úabsr   Ú
array_formÚ_is_infiniter   ÚInfinityÚ_finite_index_subgrouprf   Úindex)r7   rs   Úrrd   rY   Úinds   &&    r   r€   ÚFpGroup.orderÜ   sa  € ð  �;‰;Ò"Ø—;‘;ÐØ×ÑÒ(Ü˜d×/Ñ/×5Ñ5Ó6ˆDŒKð �{‰{Ðô �—‘Ó 1Ô$ØŸ/™/×/Ñ/Ó1ˆDŒKð �{‰{Ðô �—‘Ó! QÔ&Üœc¸t¿}º}Ó"M¹}¸!§<¡<°¥?°1×#5Ð#5¹}Ñ"MÓNÓOˆDŒKð �{‰{Ðð ×Ñ× Ò ÜŸ*™*ˆDŒKð �{‰{Ðð ×1Ñ1Ó3‰GˆDßÜ˜!Ÿ'™'“l�Ø!§-¡-° -Ó":×"@Ñ"@Ó"BÕB�”ð �{‰{Ðð #Ÿj™j¨›n�”Ø�{‰{Ðùò #Ns   Ã"Gc           	     ó¨  € \        4       pV P                   F"  pVP                  VP                  4       4       K$  	  \        V P                  4      V8:  g   R# . pV P                   F<  pTP                  V P                   Uu. uF  qTP                  V4      NK  	  up4       K>  	  \        \        V4      4      p^ \        V4      9   d   R# R# u upi )zY
Test if the group is infinite. Return `True` if the test succeeds
and `None` otherwise

TN)	Úsetr   ÚupdateÚcontains_generatorsr#   ÚappendÚexponent_sumr   r   )r7   Ú	used_gensr‡   Úabelian_relsÚrelrO   Úms   &      r   rƒ   ÚFpGroup._is_infiniteÿ   sª   € ô “Eˆ	Ø—”ˆAØ×Ñ˜Q×2Ñ2Ó4Ö5ñ ä�4—?‘?Ó# yÔ0ÙàˆØ—=”=ˆCØ×Ñ¸d¿oºoÓ N¹o¸×!1Ñ!1°!Ö!4¹oÑ NÖOñ !ä”6˜,Ó'Ó(ˆØÔ! !Ó$Ô$Ùáùò !Os   ÂC
c                ó<  € V P                  4       p\        V P                  4      pVP                  V P                  4       V'       gÔ   \        V P                  4      ^8X  d.   V.V P                   Uu. uF  qDV8w  g   K  VNK  	  up,           pMŒV P                  P                  p^ pWS9   g!   VR,          V9   g   VP                  '       d#   V^
8  d   V P                  4       pV^,          pKH  W%.V P                   Uu. uF  qDV8w  g   K  VNK  	  up,           p\        V4      ^,           ^,          pVRV pWR p	Rp
Rp^ÈpRpV'       g©   V^,          \        P                  8  d�   \        V\        P                  4      pV P                  WŒV
RR7      p
V
P                  4       '       d   T
pTpM.V P                  WœVRR7      pVP                  4       '       d   TpT	pV'       d   K¥  V^,          pK°  V'       g   R# VP                  4        XV3# u upi u upi )z¾
Find the elements of `self` that generate a finite index subgroup
and, if found, return the list of elements and the coset table of `self` by
the subgroup, otherwise return `(None, None)`

NTrj   rE   )NN)Úmost_frequent_generatorÚlistr#   Úextendr   r   r   rF   Úis_identityÚrandomr   rn   Úminrt   ro   rp   )r7   ÚsÚgenr)   rO   ÚrandÚiÚmidÚhalf1Úhalf2Údraft1Údraft2r“   rY   Úhalfs   &&             r   r…   ÚFpGroup._finite_index_subgroup  sÙ  € ð ×*Ñ*Ó,ˆÜ�D—O‘OÓ$ˆØ�‰�D—M‘MÔ"ßÜ�4—?‘?Ó# qÔ(Ø�E¨¯ªÓD© 1À¹8ŸQ˜Q©ÑDÕD‘à—‘×/Ñ/�Ø�Øœ¨¨b­°DÔ(8¸D×<L×<LÐ<LØ˜bœDØŸ;™;›=�DØ˜•F’AØ�K¨d¯oªoÓ"J©o¨ÀcÁ§1 1©oÑ"JÕJ�Ü�1‹v�a�x˜!�mˆØ�$�3�ˆØ�$�ˆØˆØˆØˆØˆß˜˜1�œz×?Ñ?Ô?Ü�A”z×7Ñ7Ó8ˆAØ×+Ñ+¨EØ'-¸$ð ,ó @ˆFà×!Ñ!×#Ò#Ø�Ø‘à×/Ñ/°Ø'-¸$ð 0ó @�à×%Ñ%×'Ò'Ø�AØ �Dß‘1Ø�Q•’ßØÐØ	�
‰
ŒØ�QˆwˆùòE Eùò #Ks   Á3HÂ HÄ HÄHc                óÈ   a€ V P                   pV P                  pV Uau. uF  o\        V3R  lV 4       4      NK  	  ppWP                  \	        V4      4      ,          # u upi )c              3   óD   <"  € T F  qP                  S4      x € K  	  R # 5ir   )Úgenerator_count)rU   r‡   rO   s   & €r   rV   Ú2FpGroup.most_frequent_generator.<locals>.<genexpr>H  s   øé € Ð8±4¨a×&Ñ& q×)Ð)³4ùs   ƒ )r#   r   Úsumr†   Úmax)r7   rd   r)   rO   Úfreqss   &  ` r   r–   ÚFpGroup.most_frequent_generatorE  sP   ø€ Ø�‰ˆØ�}‰}ˆÙBFÔGÁ$¸Q”Ô8±4Ó8Ö8Á$ˆÐGØ—K‘K¤ E£
Ó+Õ,Ð,ùò Hs   ŸAc                óð   € ^ RI pV P                  P                  p\        VP	                  ^^4      4       F<  pW!P                  V P                  4      VP                  ^R.4      ,          ,          pK>  	  V# )é    NrE   )rš   r   rF   ÚrangeÚrandintÚchoicer#   )r7   rš   r‡   rŸ   s   &   r   rš   ÚFpGroup.randomK  sZ   € ÛØ�O‰O×$Ñ$ˆÜ�v—~‘~ a¨Ó*Ö+ˆAØ—-‘- §¡Ó0°&·-±-ÀÀ2ÀÓ2GÕGÕGŠAñ ,àˆr   c                ó|   € V. 8X  d   V P                  4       # V P                  W4      p\        VP                  4      # )a  
Return the index of subgroup ``H`` in group ``self``.

Examples
========

>>> from sympy.combinatorics import free_group
>>> from sympy.combinatorics.fp_groups import FpGroup
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x**5, y**4, y*x*y**3*x**3])
>>> f.index([x])
4

)r€   rt   r   r{   )r7   rr   rs   rY   s   &&& r   r†   ÚFpGroup.indexR  s5   € ð$ �Œ7Ø—:‘:“<Ðà×&Ñ& qÓ3ˆAÜ�q—w‘w“<Ðr   c                ó²   € V P                   P                  ^8”  d    RV P                   P                  ,          pV# R\        V P                  4      ,          pV# )é   z<fp group with %s generators>z<fp group on the generators %s>)r   ÚrankÚstrr#   ©r7   Ústr_forms   & r   Ú__str__ÚFpGroup.__str__j  sI   € Ø�?‰?×Ñ "Ô$Ø6¸¿¹×9MÑ9MÕMˆHð ˆð 9¼3¸t¿¹Ó;OÕOˆHØˆr   c                óJ  € ^ RI Hp ^ RIHp V P	                  4       \
        P                  J d   \        R4      hV P                  '       d    V P                  pVP                  4       pWC3# V P                  . 4      pV P                  pV UUu. uFJ  p\        \        V4      4       Uu. uF(  q…V,          ^VP                  V4      ,          ,          NK*  	  upNKL  	  p	ppV	 Uu. uF
  q�! V4      NK  	  p	p\        V	4      pV! WWiRR7      pW0n        WC3# u upi u uppi u upi )z�
Return an isomorphic permutation group and the isomorphism.
The implementation is dependent on coset enumeration so
will only terminate for finite groups.

)ÚPermutationr]   z>Permutation presentation of infinite groups is not implementedFr^   )Úsympy.combinatoricsrÀ   rc   rZ   r€   r   r„   ÚNotImplementedErrorr6   Úimager|   r#   r±   r   r†   r   )
r7   rÀ   rZ   ÚTÚPrY   rd   rO   rŸ   Úimagess
   &         r   Ú_to_perm_groupÚFpGroup._to_perm_groupw  s  € õ 	4ÝBØ�:‰:‹<œ1Ÿ:™:Ó%Ü%ð 'Nó Oð Oà×!×!Ð!Ø×&Ñ&ˆAØ—‘“	ˆAð ˆtˆð × Ñ  Ó$ˆAØ—?‘?ˆDÙNRÔSÉdÈ´e¼CÀ»F´mÓD±m°˜•t˜A˜dŸj™j¨›m�O×,Ð,±mÔDÉdˆFÑSÙ.4Ó5©f¨�k !–n©fˆFÐ5Ü  Ó(ˆAÙ˜T d¸%Ô@ˆAØ%&Ô"Øˆtˆùò EùÓSùÚ5s   ÂDÂ(.DÃDÃ$D ÄDc                ó  € V P                  4       w  r4\        W14      ! V!  pRp\        V\        4      '       d   V.Rre. pV F/  pVP                  p	VP                  VP                  V	4      4       K1  	  V'       d
   V^ ,          # T# )a  
Given the name of a `PermutationGroup` method (returning a subgroup
or a list of subgroups) and (optionally) additional arguments it takes,
return a list or a list of lists containing the generators of this (or
these) subgroups in terms of the generators of `self`.

FT)rÇ   ÚgetattrrT   r   r#   rŽ   Úinvert)
r7   Úmethod_nameÚargsrÅ   rÄ   Úperm_resultÚsingleÚresultr.   rd   s
   &&*       r   Ú_perm_group_listÚFpGroup._perm_group_list�  s€   € ð ×"Ñ"Ó$‰ˆÜ˜aÔ-¨tÑ4ˆØˆÜ�kÔ#3×4Ò4Ø#. -°˜ØˆÛ ˆEØ×#Ñ#ˆDØ�M‰M˜!Ÿ(™( 4›.Ö)ñ !÷ #ˆv�a�yÐ.¨Ð.r   c                ó$   € V P                  R4      # )zg
Return the list of lists containing the generators
of the subgroups in the derived series of `self`.

Úderived_series©rÑ   r;   s   &r   rÔ   ÚFpGroup.derived_series£  s   € ð ×$Ñ$Ð%5Ó6Ð6r   c                ó$   € V P                  R4      # )zm
Return the list of lists containing the generators
of the subgroups in the lower central series of `self`.

Úlower_central_seriesrÕ   r;   s   &r   rØ   ÚFpGroup.lower_central_series«  s   € ð ×$Ñ$Ð%;Ó<Ð<r   c                ó$   € V P                  R4      # )z9
Return the list of generators of the center of `self`.

ÚcenterrÕ   r;   s   &r   rÛ   ÚFpGroup.center³  s   € ð
 ×$Ñ$ XÓ.Ð.r   c                ó$   € V P                  R4      # )zC
Return the list of generators of the derived subgroup of `self`.

Úderived_subgrouprÕ   r;   s   &r   rÞ   ÚFpGroup.derived_subgroup»  s   € ð
 ×$Ñ$Ð%7Ó8Ð8r   c                ód   € V P                  4       ^,          pV! V4      pV P                  RV4      # )zh
Return the list of generators of the centralizer of `other`
(a list of elements of `self`) in `self`.

Úcentralizer©rÇ   rÑ   ©r7   ÚotherrÄ   s   && r   rá   ÚFpGroup.centralizerÃ  s3   € ð ×ÑÓ! !Õ$ˆÙ�%“ˆØ×$Ñ$ ]°EÓ:Ð:r   c                ód   € V P                  4       ^,          pV! V4      pV P                  RV4      # )zk
Return the list of generators of the normal closure of `other`
(a list of elements of `self`) in `self`.

Únormal_closurerâ   rã   s   && r   rç   ÚFpGroup.normal_closureÍ  s4   € ð ×ÑÓ! !Õ$ˆÙ�%“ˆØ×$Ñ$Ð%5°uÓ=Ð=r   c                óF   € V P                  4       ^ ,          p\        W!4      # )zm
Given an attribute of a `PermutationGroup`, return
its value for a permutation group isomorphic to `self`.

)rÇ   rÊ   )r7   ÚattrrÅ   s   && r   Ú_perm_propertyÚFpGroup._perm_property×  s"   € ð ×ÑÓ! !Õ$ˆÜ�qÓÐr   c                ó$   € V P                  R4      # )z
Check if `self` is abelian.

Ú
is_abelian©rë   r;   s   &r   rî   ÚFpGroup.is_abelianà  s   € ð ×"Ñ" <Ó0Ð0r   c                ó$   € V P                  R4      # )z 
Check if `self` is nilpotent.

Úis_nilpotentrï   r;   s   &r   rò   ÚFpGroup.is_nilpotentè  s   € ð ×"Ñ" >Ó2Ð2r   c                ó$   € V P                  R4      # )z
Check if `self` is solvable.

Úis_solvablerï   r;   s   &r   rõ   ÚFpGroup.is_solvableð  s   € ð ×"Ñ" =Ó1Ð1r   c                ó\   € V P                  4       w  rVP                  VP                  4      # )z
List the elements of `self`.

)rÇ   rË   Úelements©r7   rÅ   rÄ   s   &  r   rø   ÚFpGroup.elementsø  s'   € ð ×"Ñ"Ó$‰ˆØ�x‰x˜Ÿ
™
Ó#Ð#r   c                ó¬   € \        V P                  4      ^8:  d   R#  V P                  4       w  rVP                  #   \         d    \        R4      hi ; i)z&
Return ``True`` if group is Cyclic.

Tz2Check for infinite Cyclic group is not implemented)r   r#   rÇ   rÂ   Ú	is_cyclicrù   s   &  r   rü   ÚFpGroup.is_cyclic  s\   € ô ˆt�‰Ó 1Ô$Ùð	<Ø×&Ñ&Ó(‰DˆAð �{‰{Ðøô #ô 	<Ü%ð ';ó <ð <ð	<ús	   ž< ¼Ac                ó|   €  V P                  4       w  rVP                  4       #   \         d    \        R4      hi ; i)z'
Return Abelian Invariants of a group.
z7abelian invariants is not implementedfor infinite group)rÇ   rÂ   Úabelian_invariantsrù   s   &  r   rÿ   ÚFpGroup.abelian_invariants  óK   € ð	<Ø×&Ñ&Ó(‰DˆAð ×#Ñ#Ó%Ð%øô #ô 	<Ü%ð ';ó <ð <ð	<úó   ‚$ ¤;c                ó|   €  V P                  4       w  rVP                  4       #   \         d    \        R4      hi ; i)z8
Return subnormal series of maximum length for a group.
z7composition series is not implementedfor infinite group)rÇ   rÂ   Úcomposition_seriesrù   s   &  r   r  ÚFpGroup.composition_series  r  r  )
r4   r1   r2   r3   r6   r5   r0   r   r#   r   ©NF)ri   NNF)ri   r   ).Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úis_groupÚ
is_FpGroupÚis_PermutationGroupr8   r   r>   rA   rJ   ÚpropertyrF   rP   rf   rt   rx   r|   r€   rƒ   r…   r–   rš   r†   r½   Ú__repr__rÇ   rÑ   rÔ   rØ   rÛ   rÞ   rá   rç   rë   rî   rò   rõ   rø   rü   rÿ   r  Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r   r   2   s/  ø‡ € ñð €HØ€JØÐòò(*òò3òð ñ(ó ð(ò$ô$ôLò8%ôô,!òFô,.ò`-òô ò0ð €Hòò2/ò&7ò=ò/ò9ò;ò>ò ð ñ1ó ð1ð ñ3ó ð3ð ñ2ó ð2ð ñ$ó ð$ð ñó ðò	&÷	&ð 	&r   r   c                   óV   a a€ ] tR tRt oRtR	V 3R lltR tR tR tR t	]	t
RtVtV ;t# )
Ú
FpSubgroupi'  zâ
The class implementing a subgroup of an FpGroup or a FreeGroup
(only finite index subgroups are supported at this point). This
is to be used if one wishes to check if an element of the original
group belongs to the subgroup

c                óÆ   <€ \         SV `  4        Wn        \        V Uu0 uF  qDVP                  8w  g   K  VkK  	  up4      V n        R V n        R V n        W0n        R # u upi r   )	Úsuperr8   Úparentr—   rF   r#   Ú
_min_wordsrY   Únormal)r7   ÚGrd   r  rO   Ú	__class__s   &&&& €r   r8   ÚFpSubgroup.__init__/  sQ   ø€ Ü‰ÑÔØŒÜ©4ÓC©4 a¸¿
¹
±?§ ©4ÑCÓDˆŒØˆŒØˆŒØŽùò  Ds
   ŸA¶Ac                ó$  a aaaa€ \        S P                  \        4      '       EdÒ   S P                  Ef|   R p. pS P                   F<  pS P
                  '       d   VP                  4       pVP                  V! V4      4       K>  	  V EF  pV EF  pWV8X  g%   \        V\        4      '       g   VR,          V8X  d   K0  \        V\        4      '       d(   V^ ,          ^ ,          V^ ,          ^ ,          R,          r‡M!V^ ,          V\        V4      ^,
          ,          r‡\        V\        4      '       d(   V^ ,          ^ ,          V^ ,          ^ ,          R,          r©M!V^ ,          V\        V4      ^,
          ,          r©YVrË\        V\        4      '       d-   V^ ,          V^,          ,          V^ ,          R,          ,          p\        V\        4      '       d-   V^ ,          V^,          ,          V^ ,          R,          ,          pV	R,          V8X  d>   W¼,          P                  '       g&   V! W¼,          4      pWÓ9  d   VP                  V4       V
R,          V8X  g   EKÎ  WË,          P                  '       d   EKé  V! WË,          4      pWÓ9  g   EK   VP                  V4       EK  	  EK  	  VS n        S P                  oVV 3R lo/ oVVV3R loS P
                  '       d   VP                  4       pS! V4      # S P                  f-   S P                  P                  S P                  4      pVS n        ^ pS P                  p\        \        V4      4       F5  pVP                  V,          VP                  VV,          ,          ,          pK7  	  V^ 8H  # )Nc                 ój   € V P                  R R7      w  rVP                  '       g   W!3.# W R,          .# )T©ÚremovedrE   )Úcyclic_reductionr™   )ÚwÚpr‡   s   &  r   Ú_processÚ)FpSubgroup.__contains__.<locals>._processA  s7   € ð ×-Ñ-°dÐ-Ó;‘D�AØŸ=Ÿ=˜=Ø!" ˜x˜à ! b¥5˜zÐ)r   c                 ól  <€ V P                  R R7      w  rVP                  '       g   SP                  '       d   V S9   # S Uu. uF4  p\        V\        4      '       g   K  V^ ,          V8X  g   K+  V^,          NK6  	  ppV Uu. uF  q P                  V4      '       g   K  VNK  	  up. 8g  # u upi u upi )Tr   )r"  r™   r  rT   r   Úpower_of)r#  r‡   rœ   ÚtÚ	min_wordsr7   s   &   €€r   Ú_is_subwordÚ,FpSubgroup.__contains__.<locals>._is_subword‚  s�   ø€ ð ×)Ñ)°$Ð)Ó7‘�Ø—=—=�= D§K§K KØ 	™>Ð)á'0ó O¡y !´J¸qÄ%×4HœØDEÀaÅDÈAÁIô ˜˜1Ÿ˜¡y�Að Oá'(Ó:¡q !¯J©J°q¯MŸA˜A¡qÑ:¸bÑ@Ð@ùòOùâ:s   ÁB,Á B,Á0B,ÂB1Â B1c                 ó&  <€ \        V 4      ^ 8X  d   R# ^ pV\        V 4      8  dl   V^,          pV P                  ^ V4      pS! V4      '       g   K;  V P                  V\        V 4      4      pVS9  d   S! V4      SV&   SV,          '       g   Ky  R# R# )r°   TF)r   Úsubword)r#  rŸ   ÚprefixÚrestr+  Ú_word_breakÚknowns   &   €€€r   r1  Ú,FpSubgroup.__contains__.<locals>._word_break‘  s‚   ø€ ô �q“6˜Q”;ÙØ�Øœ#˜a›&”jØ˜•F�AØŸY™Y q¨!›_�FÙ& v×.Ò.Ù ØŸ9™9 Q¬¨A«Ó/�DØ 5Ô(Ù&1°$Ó&7˜˜d™Ø˜T—{–{Ù#Ùr   rE   )rT   r  r   r  r#   r  r"  r˜   r   r   r™   rY   rt   r±   r{   ÚA_dict)r7   rO   r%  rd   r#  Úw1Úw2Ús1Ús2Úr1Úr2Úp1Úp2ÚnewrY   rŸ   Újr+  r1  r2  r*  s   f&               @@@@r   rP   ÚFpSubgroup.__contains__7  s“  ü€ ä�d—k‘k¤9×-Ó-Ø�‰Ó&ò*ð �ØŸœ�AØ—{—{�{Ø×.Ñ.Ó0˜Ø—K‘K¡¨£Ö,ñ )ô
 �BÜ"˜àœ8¬J°r¼5×,AÒ,AØ<>À½FÀb¼LÙ$ô
 & b¬%×0Ò0à%'¨¥U¨1¥X¨r°!­u°Q­x¸­|¡à%'¨¥U¨B¬s°2«w°q­y­M ä% b¬%×0Ò0à%'¨¥U¨1¥X¨r°!­u°Q­x¸­|¡à%'¨¥U¨B¬s°2«w°q­y­M ð "$˜BÜ% b¬%×0Ò0Ø!# A¥ r¨!¥u¥¨R°­U°B­YÕ!6˜BÜ% b¬%×0Ò0Ø!# A¥ r¨!¥u¥¨R°­U°B­YÕ!6˜Bð ˜r�6 Rœ<°µ×0C×0CÐ0CÙ"*¨2­5£/˜CØ"œØ $§¡¨CÔ 0à˜r�6 RŸ<°µ×0C×0CÓ0CÙ"*¨2­5£/˜CØ"ŸØ $§¡¨C× 0ôM #ñ ðR #'�”àŸ™ˆIö	Að ˆE÷ð$ �{�{ˆ{Ø×&Ñ&Ó(�Ù˜q“>Ð!à�v‰vŠ~Ø—K‘K×1Ñ1°$·/±/ÓB�Ø�”ØˆAØ—‘ˆAÜœ3˜q›6–]�Ø—G‘G˜A•J˜qŸx™x¨¨!­�~Õ.’ñ #à˜‘6ˆMr   c                ó”  € V P                   '       g   \        P                  # \        V P                  \
        4      '       d   \        P                  # V P                  f,   V P                  P                  V P                   4      pWn        V P                  P                  4       \        V P                  P                  4      ,          # r   )r#   r   ÚOnerT   r  r   r„   rY   rt   r€   r   r{   )r7   rY   s   & r   r€   ÚFpSubgroup.order°  s|   € Ø��ˆÜ—5‘5ˆLÜ�d—k‘k¤9×-Ò-Ü—:‘:ÐØ�6‰6Š>Ø—‘×-Ñ-¨d¯o©oÓ>ˆAØŒFð �{‰{× Ñ Ó"¤3 t§v¡v§|¡|Ó#4Õ4Ð4r   c                óB  € \        V P                  \        4      '       dV   \        \	        V P
                  4      4       Uu. uF  pR V,          NK  	  pp\        RP                  V4      4      ^ ,          # V P                  P                  V P                  R7      # u upi )zx_%dú, r[   )
rT   r  r   r±   r   r#   r   Újoinrf   rY   )r7   rŸ   Úgen_symss   &  r   Ú
to_FpGroupÚFpSubgroup.to_FpGroup¼  sx   € Ü�d—k‘k¤9×-Ò-Ü,1´#°d·o±oÓ2FÔ,GÓHÑ,G q˜ Ÿ˜Ñ,GˆHÐHÜ˜dŸi™i¨Ó1Ó2°1Õ5Ð5Ø�{‰{×#Ñ# d§f¡fÐ#Ó-Ð-ùò Is   ÁBc                ó®   € \        V P                  4      ^8”  d   R\        V P                  4      ,          pV# R\        V P                  4      ,          pV# )r¸   z <fp subgroup with %s generators>z"<fp subgroup on the generators %s>)r   r#   rº   r»   s   & r   r½   ÚFpSubgroup.__str__Â  sG   € Üˆt�‰Ó "Ô$Ø9¼CÀÇÁÓ<PÕPˆHð ˆð <¼cÀ$Ç/Á/Ó>RÕRˆHØˆr   )rY   r  r#   r  r  ©F)r  r  r	  r
  r  r8   rP   r€   rG  r½   r  r  r  Ú__classcell__)r  r  s   @@r   r  r  '  s.   ù‡ € ñ÷òwòr
5ò.òð ‡H€Hr   r  c           	     óT  € \        V . 4      pV P                  p^pV Uu0 uF  p\        V4      V8”  g   K  VkK  	  pp\        V4      V,
           Uu0 uF  qfP	                  4       kK  	  ppVP                  V4      p	. p
\        W£W“P                  ^ ,          WqV4       V
# u upi u upi )aÐ  
Implements the Low Index Subgroups algorithm, i.e find all subgroups of
``G`` upto a given index ``N``. This implements the method described in
[Sim94]. This procedure involves a backtrack search over incomplete Coset
Tables, rather than over forced coincidences.

Parameters
==========

G: An FpGroup < X|R >
N: positive integer, representing the maximum index value for subgroups
Y: (an optional argument) specifying a list of subgroup generators, such
that each of the resulting subgroup contains the subgroup generated by Y.

Examples
========

>>> from sympy.combinatorics import free_group
>>> from sympy.combinatorics.fp_groups import FpGroup, low_index_subgroups
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x**2, y**3, (x*y)**4])
>>> L = low_index_subgroups(f, 4)
>>> for coset_table in L:
...     print(coset_table.table)
[[0, 0, 0, 0]]
[[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 3, 3]]
[[0, 0, 1, 2], [2, 2, 2, 0], [1, 1, 0, 1]]
[[1, 1, 0, 0], [0, 0, 1, 1]]

References
==========

.. [1] Holt, D., Eick, B., O'Brien, E.
       "Handbook of Computational Group Theory"
       Section 5.4

.. [2] Marston Conder and Peter Dobcsanyi
       "Applications and Adaptions of the Low Index Subgroups Procedure"

)r   r   r   r‹   Úidentity_cyclic_reductionÚ
conjugatesÚdescendant_subgroupsÚA)r  ÚNÚYrY   ÚRÚlen_short_relr’   ÚR2ÚR1Ú	R1_c_listr   s   &&&        r   Úlow_index_subgroupsrY  Ð  s    € ôR 	�1�bÓ€AØ	�
‰
€Aà€Mñ Ó	7™�#œc #›h¨Ñ6�#ˆ#™€BÐ	7ô 69¸³V¸b¶[Ó	A±[¨c×
'Ñ
'Ö
)±[€BÐ	AØ—‘˜RÓ €IØ
€AÜ˜˜y¯#©#¨a­&°"¸Ô;Ø€Hùò 
8ùò 
Bs   ŸB ¶B ÁB%c                 ó¤  € VP                   pVP                  pVP                  4       '       dM   \        WAP                  4       F  w  ršVP                  W©4      '       d   K   R # 	  V P                  ! V4       R # \        \        \        VP                  4      4      VP                  4       F+  w  r£VP                  V
,          Ws,          ,          e   K)  Y£rË M	  VP                  VP                  .,           pV FP  pWå8  g   K  WáP                  8X  g&   VP                  V,          VX,          ,          e   K@  \        WW$VXXWæ4	       KR  	  R # r   )r4  Ú
A_dict_invro   r   ÚomegaÚ
scan_checkrŽ   r±   r   r{   rQ  ÚnÚtry_descendant)r   rY   rX  ÚxrV  rR  rS  r4  r[  r#  ÚalphaÚundefined_cosetÚundefined_genÚreachÚbetas   &&&&&&&        r   rP  rP  	  sñ   € Ø�X‰X€FØ—‘€JØ‡}�}‡‚ô   §G¡GÖ,‰HˆAØ—<‘< ×)Ô)Úñ -ð 	
�Š�Žô  ¤¤c¨!¯'©'£lÓ 3°Q·S±SÖ9‰HˆEØ�w‰w�u�~˜f�iÕ(Ô0à16 Ùñ	 :ð —‘˜1Ÿ3™3˜%•ˆÛˆDØŽxØŸ3™3”; !§'¡'¨$¥-°
¸=Õ0IÕ"JÔ"RÜ" 1¨¸¸?Ø)¨4ö4ó r   c	           	     óÞ  € VP                  4       p	WyP                  8X  dX   Wt8  dR   V	P                  P                  R.\	        V	P
                  4      ,          4       V	P                  P                  V4       WyP                  V,          V	P                  V,          &   WYP                  V,          V	P                  V,          &   V	P                  P                  WV34       V	P                  W)P                  V,          ,          W)P                  V,          ,          4      '       g   R# V F  p
V	P                  ^ V
4      '       d   K   R# 	  \        W˜4      '       d   \        W	W&W4V4       R# R# )zN
Solves the problem of trying out each individual possibility
for `\alpha^x.

N)Úcopyr^  r{   rŽ   r   rQ  r$  r4  r[  Údeduction_stackÚprocess_deductions_checkr]  Úfirst_in_classrP  )r   rY   rX  rV  rR  ra  r`  re  rS  ÚDr#  s   &&&&&&&&&  r   r_  r_  %  sÿ   € ð 	
�‰‹€AØ�s‰s„{�t”xØ	�‰�‰˜�vœc !§#¡#›h•Ô'Ø	�‰�
‰
�4ÔØ"&‡G�GˆE…N�1—8‘8˜A•;ÑØ%*‡G�GˆD…M�!—,‘,˜q•/Ñ"Ø×Ñ×Ñ˜e˜ZÔ(Ø×%Ñ% i·±¸µÕ&<Ø—l‘l 1•oÕ&÷(ò (áÛˆØ�|‰|˜A˜q×!Ô!Úñ ô �a×ÒÜ˜Q 9°¸Ö:ñ r   c                ó  € V P                   pRpR.V,          pR.V,          pRp\        ^V4       EFT  p\        V^,           4       F  pRWEV,          &   K  	  V F7  p	V P                  V,          V P                  V	,          ,          V8w  g   K5  Rp M	  V'       d   RpKq  Wu^ &   ^ WG&   ^ p\        V4       FÊ  pV P                   F©  p
V P                  V,          V P                  V
,          ,          pV P                  WX,          ,          V P                  V
,          ,          pVe   Vf   Rp MBWL,          f   V^,          pW4V&   WÅV&   WL,          V8  d      R# WL,          V8”  g   K§  Rp M	  V'       g   KÆ  Rp EKR  	  EKW  	  R# )aw  
Checks whether the subgroup ``H=G1`` corresponding to the Coset Table
could possibly be the canonical representative of its conjugacy class.

Parameters
==========

C: CosetTable

Returns
=======

bool: True/False

If this returns False, then no descendant of C can have that property, and
so we can abandon C. If it returns True, then we need to process further
the node of the search tree corresponding to C, and so we call
``descendant_subgroups`` recursively on C.

Examples
========

>>> from sympy.combinatorics import free_group
>>> from sympy.combinatorics.fp_groups import FpGroup, CosetTable, first_in_class
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x**2, y**3, (x*y)**4])
>>> C = CosetTable(f, [])
>>> C.table = [[0, 0, None, None]]
>>> first_in_class(C)
True
>>> C.table = [[1, 1, 1, None], [0, 0, None, 1]]; C.p = [0, 1]
>>> first_in_class(C)
True
>>> C.table = [[1, 1, 2, 1], [0, 0, 0, None], [None, None, None, 0]]
>>> C.p = [0, 1, 2]
>>> first_in_class(C)
False
>>> C.table = [[1, 1, 1, 2], [0, 0, 2, 0], [2, None, 0, 1]]
>>> first_in_class(C)
False

# TODO:: Sims points out in [Sim94] that performance can be improved by
# remembering some of the information computed by ``first_in_class``. If
# the ``continue alpha`` statement is executed at line 14, then the same thing
# will happen for that value of alpha in any descendant of the table C, and so
# the values the values of alpha for which this occurs could profitably be
# stored and passed through to the descendants of C. Of course this would
# make the code more complicated.

# The code below is taken directly from the function on page 208 of [Sim94]
# nu[alpha]

NFTrE   )r^  r±   r{   r4  rQ  )rY   rS  r^  ÚlamdaÚnuÚmuÚ
next_alphara  re  r#  r`  ÚgammaÚdeltas   &&           r   rj  rj  <  sk  € ðl 	
�‰€Aà€Eà
ˆ��€Bà
ˆ��€Bð €Jô �q˜!—ˆä˜% �'–NˆDØˆB�$�x‹Lñ #ó ˆAð �w‰w�u�~˜aŸh™h q�kÕ*¨eÖ3à!�
Ùñ ÷ ØˆJÙàˆ1‰Øˆ‰	àˆÜ˜!–HˆDØ—S”S�ØŸ™ � a§h¡h¨q¥kÕ2�ØŸ™ ¥Õ)¨!¯(©(°1­+Õ6�ð ’= E¢Mà!%�JÙØ•9Ò$à˜Q•J�EØ %�u‘IØ %�u‘IØ•9˜uÔ$Ü Ø•9˜uÖ$à!%�JÙñ' ÷( ‰zØ"�
Ûô/ ñ/ ñ^ r   Úchange_gensFc                ól  € \        V4      ^8X  d�   \        V^ ,          \        4      '       g   \        R4      hV^ ,          p\	        VP
                  VP                  V R7      w  r4V'       d   \        V^ ,          P                  V4      # \        \        . 4      . 4      # \        V4      ^8X  dI   V^ ,          R,          V^,          R,          rCV'       g   W43# V^ ,          P                  P                  pM \        V4      ^ 8X  d   RpMRp\        V4      h. p. p\        V4      \        V4      8X  gC   TpV '       d,   \        V4      \        V4      8X  g   Tp\        W4V4      w  r4K3  \        V4      pK[  V '       d°   V U	u. uF  q™P                  ^ ,          ^ ,          NK  	  p
p	\        V
4      ^ ,          pVP                  pVP
                  p\!        \#        W£4      4      p\%        V4       F:  w  rÞVP                  pTpV F  w  ppVVV,          V,          ,          pK  	  VWM&   K<  	  W43# u up	i )aŽ  
For an instance of `FpGroup`, return a simplified isomorphic copy of
the group (e.g. remove redundant generators or relators). Alternatively,
a list of generators and relators can be passed in which case the
simplified lists will be returned.

By default, the generators of the group are unchanged. If you would
like to remove redundant generators, set the keyword argument
`change_gens = True`.

z+The argument must be an instance of FpGroup©rs  ºNNNzNot enough argumentszToo many arguments)r   rT   r   Ú	TypeErrorÚsimplify_presentationr#   r   r.   r   rF   ÚRuntimeErrorr‹   Úelimination_technique_1Ú_simplify_relatorsr‚   r   ÚdictÚzipÚ	enumerate)rs  rÍ   r  rd   r)   rF   r“   Ú	prev_gensÚ	prev_relsrO   ÚsymsÚFÚsubsr>  r‡   Úar’   r%   r$  s   $*                 r   rx  rx  ³  sÑ  € ô ˆ4ƒy�A„~Ü˜$˜q�'¤7×+Ò+ÜÐIÓJÐJØ��GˆÜ*¨1¯<©<¸¿¹Ø:EôG‰
ˆçÜ˜4 �7Ÿ=™=¨$Ó/Ð/Ü”y “} bÓ)Ð)Ü	ˆT‹�aŒØ˜!•W˜Q•Z  a¥¨¥ˆdßØ�:ÐØ˜•7—=‘=×)Ñ)‰äˆt‹9˜Œ>Ø&‰Aà$ˆAÜ˜1‹oÐà€IØ€IÜ�)‹n¤ D£	Ô)Øˆ	ß¤# i£.´C¸³IÔ"=ØˆIÜ0°¸XÓF‰JˆD‘$Ü! $Ó'ŠçÙ,0Ó1©D q—‘˜Q• ×"Ð"©DˆÐ1Ü�tÓ˜QÕˆØ—:‘:ˆØ�|‰|ˆÜ”C˜“OÓ$ˆÜ˜d–O‰DˆAØ—‘ˆAØˆCÛ‘��QØ˜$˜s�) Q�,Õ&’ñ àˆD‹Gñ $ð ˆ:Ðùò 2s   Æ"H1c                óØ  € V R,          p V '       g   . # V ^ ,          P                   P                  p/ p\        \        V 4      4       FÁ  pW,          pVP	                  4       ^8X  g   K"  V^ ,          p\        VP                  ^ ,          ^,          4      pVP                  ^ ,          ^,          ^ 8  d   W,          R,          W&   VR,          pWR9   d+   \        WbV,          P                  ^ ,          ^,          4      pWV,          W%&   KÃ  	  \        VP                  4       4      p\        V 4       FÃ  w  r4WG9   d   K  VP                  VRR7      pVP                  4        F‹  pWR9   g   K  W%,          P                  ^ ,          ^,          pV^,           ^,          pVP                  WX,          WXV,
          ,          RR7      pVP                  WX) ,          WXV,
          ) ,          RR7      pK�  	  W@V&   KÅ  	  V  U	u. uF  q™P                  4       NK  	  p p	W,          p \        \        V 4      4      p V P!                  4         V P#                  V4       V # u up	i   \$         d     T # i ; i)a¼  
Simplifies a set of relators. All relators are checked to see if they are
of the form `gen^n`. If any such relators are found then all other relators
are processed for strings in the `gen` known order.

Examples
========

>>> from sympy.combinatorics import free_group
>>> from sympy.combinatorics.fp_groups import _simplify_relators
>>> F, x, y = free_group("x, y")
>>> w1 = [x**2*y**4, x**3]
>>> _simplify_relators(w1)
[x**3, x**-1*y**4]

>>> w2 = [x**2*y**-4*x**5, x**3, x**2*y**8, y**5]
>>> _simplify_relators(w2)
[x**-1*y**-2, x**-1*y*x**-1, x**3, y**5]

>>> w3 = [x**6*y**4, x**4]
>>> _simplify_relators(w3)
[x**4, x**2*y**4]

>>> w4 = [x**2, x**5, y**3]
>>> _simplify_relators(w4)
[x, y**3]

rv  T©Ú_allrE   )r.   rF   r±   r   Únumber_syllablesr�   r‚   r   r—   Úvaluesr~  Úeliminate_wordsr�   Úeliminate_wordrN  r‹   ÚsortÚremovera   )
r)   rF   ÚexpsrŸ   r’   rO   ÚexpÚone_syllables_wordsÚmax_expr‡   s
   &         r   r{  r{  ë  s  € ð: ��7€DçØˆ	à�A�w�}‰}×%Ñ%€Hð €DÜ”3�t“9ÖˆØ�gˆØ×ÑÓ! QÖ&Ø�A•ˆAÜ�c—n‘n QÕ'¨Õ*Ó+ˆCØ�~‰~˜aÕ  Õ# aÔ'Ø�' 2�+�‘Ø�r•E�ØŒyÜ˜# A�w×1Ñ1°!Õ4°QÕ7Ó8�Ø•fˆD‹Gñ ô ˜tŸ{™{›}Ó-Ðô ˜D–/‰ˆØÔ%ÙØ×!Ñ!Ð"5¸dÐ!ÓCˆð ×(Ñ(Ö*ˆAØŽyØ•g×(Ñ(¨Õ+¨AÕ.�Ø �7 Q�,�Ø×(Ñ(¨­°qÀ3½;Õ7GÐPTÐ(ÓU�Ø×(Ñ(¨¨X­¸Àc½k¸NÕ8KÐTXÐ(ÓY’ñ +ð ˆQ‹ñ "ñ 48Ó8±4¨a×'Ñ'Ö)±4€DÐ8àÕ€DÜ”�D“	‹?€DØ‡I�I„KðØ�‰�HÔð €Kùò 9øô ô ØØ€Kðús   Ç;IÉI ÉI)É(I)c                 óN  a€ VR ,          pVP                  4        V R ,          p / p. p\        4       pV EFD  pVP                  4       o\        ;QJ d    V3R lV 4       F  '       g   K   RM	  RM! V3R lV 4       4      '       d   KV  \	        S4      oSP                  RR7       S FË  pVP                  V4      ^8X  g   K  Wu9  g   K#  VP                  V4      pVP                  Wx,          4      p	VP                  V	^,           \        V4      4      p
VP                  ^ V	4      pW«,          pVRV,          ,          W7&   VP                  VP                  4       4       VP                  V4        EKB  	  EKG  	  V Uu. uF  qÝV9  g   K  VNK  	  ppV Uu. uF#  qÝP                  VRR7      P                  4       NK%  	  pp\	        \        V4      4      p VP                  V4       V  Uu. uF  qîV9  g   K  VNK  	  p pW3# u upi u upi   \         d     L3i ; iu upi )rv  c              3   ó,   <"  € T F	  qS9   x € K  	  R # 5ir   r(   )rU   rO   Úcontained_genss   & €r   rV   Ú*elimination_technique_1.<locals>.<genexpr>K  s   øé € Ð;©N q�NÖ"«Nùs   ƒTF©Úreverser†  rE   )rŒ  r‹   r�   Úanyr—   r©   r�   r†   r.  r   rŒ   rŽ   rŠ  rN  r�  ra   )rd   r)   rF   Úredundant_gensÚredundant_relsr�   r’   r�   ÚkÚ	gen_indexÚbkÚfwÚchir‡   rO   r”  s   &&&            @r   rz  rz  <  sá  ø€ Ø��7€Dð 	‡I�I„KØ��7€DØ€NØ€NÜ“€Iô ˆð ×0Ñ0Ó2ˆß‹3Ô;©NÓ;�3�3Š3Ô;©NÓ;×;Ò;ÙÜ˜nÓ-ˆØ×Ñ dÐÔ+Û!ˆCØ×"Ñ" 3Ó'¨1Ö,°Ö1EØ×$Ñ$ SÓ)�ØŸI™I c¥fÓ-�	Ø—[‘[ ¨Q¥´°C³Ó9�Ø—[‘[  IÓ.�Ø•e�Ø&)¨B¨q­D¥k�Ñ#Ø× Ñ  ×!8Ñ!8Ó!:Ô;Ø×%Ñ% cÔ*Ûô "ñ ñ& Ó7‘t�!¨Ñ6�AˆA‘t€DÐ7á`dÓeÑ`dÐ[\×Ñ˜n°TÐÓ:×TÑTÖVÑ`d€DÐeÜ”�D“	‹?€DðØ�‰�HÔñ Ó7‘t�!¨Ñ6�AˆA‘t€DÐ7Øˆ:Ðùò 8ùâeøô ô Ùðüâ7s0   ÆHÆHÆ)HÇH Ç/H"Ç<H"ÈHÈHc                óF  € . p^pV P                   pVP                  pV'       d   / p/ pVP                  V^ &   \        V P                  4       Uu. uF   pR.\        V P                  4      ,          NK"  	  upV n        \        V P                  V P                  4       EFU  w  ršV P                  V	,          V P                  V
,          ,          pW³8X  dv   RV P                  V	,          V P                  V
,          &   RV P                  V,          V P                  V
,          &   V^,          pV'       d   XV	,          V
,          W{&   Kª  K¬  W¥9   g   K´  V P                  V	,          V P                  V
,          ,          e   Kã  V
: RV	: 2pVP                  V4       WÀP                  V	,          V P                  V
,          &   V'       g   EK.  XV	,          V
,          W{,          R,          ,          XV&   EKX  	  \        \        RP!                  V4      4      4      pVP#                  ^ 4      V n        WÐn        V'       d   XV n        \        \        \        V P                  4      4      \        \        V P                  4      4      4       EF  w  rŽV P                  V,          V,          R8X  d-   V P$                  P                  V P                  V,          V&   KQ  \+        V P                  V,          V,          \,        4      '       g   K�  V P&                  VP/                  V P                  V,          V,          4      ,          pWðP                  V,          V&   V P                  V,          V,          pVR,          V P                  V,          V^,           &   EK  	  R# u upi )z½
Parameters
==========

C -- Coset table.
homomorphism -- When set to True, return a dictionary containing the images
                 of the presentation generators in the original group.
Nz
<identity>Ú_rD  rE   )r   r#   rF   r±   r^  r   rQ  rÅ   r   r\  r{   r4  r[  rŽ   r—   r   rE  ÚpopÚ_schreier_free_groupÚ_schreier_generatorsÚ_schreier_gen_elemrT   rº   r†   )rY   rZ   Úyrq  ÚfÚXre   ÚtaurŸ   ra  r`  re  Ú	y_alpha_xÚgrp_gensr>  r‡   s   &&              r   Údefine_schreier_generatorsr¬  j  sz  € ð 	€AØ€EØ	�
‰
€AØ	�‰€Aßð ˆàˆØ—‘ˆˆA‰Ü$)¨!¯#©#¤JÓ
/¡J˜qˆDˆ6”#�a—c‘c“(�?ˆ?¡JÑ
/€A„CÜ˜AŸG™G Q§S¡S×)‰ˆØ�w‰w�u�~˜aŸh™h q�kÕ*ˆØŒ=Ø&2ˆA�C‰C��J�q—x‘x •{Ñ#Ø)5ˆA�C‰C��I�a—l‘l 1•oÑ&Ø�Q�JˆEßØ �J q�L�“	ñ àŽV˜Ÿ™˜E�
 1§8¡8¨A¥;Õ/Ô7Û#$¢eÐ,ˆIØ�H‰H�YÔØ&/�C‰C��J�q—x‘x •{Ñ#ßŠ|Ø#& u¥:¨a¥<°µ	¸2µÕ#=��iÔ ñ *ô ”J˜tŸy™y¨›|Ó,Ó-€HØ%Ÿ\™\¨!›_€AÔØ%ÔßØ$ˆÔäœœc !§#¡#›h›¬¬s°1·3±3«x«×9‰ˆà�3‰3ˆq�6�!�9˜Ô$Ø×.Ñ.×7Ñ7ˆA�C‰C��F�1‹IÜ˜Ÿ™˜A�˜q�	¤3×'Ô'Ø×&Ñ& q§w¡w¨q¯s©s°1­v°a­yÓ'9Õ:ˆAØ�C‰C��F�1‰IØ—7‘7˜1•:˜a•=ˆDØ  "�uˆA�C‰C��I�a˜!•eÔó :ùò+ 0s   Á&Nc           
      ó  a€ V P                   P                  pV UUu. uF+  p\        V P                  4       F  p\	        WV4      NK  	  K-  	  pppV Uu0 uF  p\        V4      ^8X  g   K  VkK  	  upo\        \        V3R lV4      4      p\        \        V4      4       F"  pWE,          pVP                  SRR7      pWdV&   K$  	  V P                   Uu. uF  pVS9   d   K  VR,          S9   d   K  VNK   	  upV n	        ^ pV\        V4      8  dY   WE,          pV^,           pV\        V4      8  d-   VP                  WG,          4      '       d   WG K1  V^,          pK<  V^,          pKh  W@n        R# u uppi u upi u upi )é   c                 ó   <€ V S9  # r   r(   )r’   Úorder_1_genss   &€r   Ú<lambda>Ú'reidemeister_relators.<locals>.<lambda>£  s
   ø€  3¨lÒ#:r   Tr†  NrE   )r   r   r±   r^  Úrewriter   r—   ÚfilterrŠ  r¤  Úis_cyclic_conjugateÚ_reidemeister_relators)	rY   rT  rB   Úcosetr)   rŸ   r#  r>  r°  s	   &       @r   Úreidemeister_relatorsr¸  �  s[  ø€ Ø	�
‰
×Ñ€AÙ01ÔJ±¨¼uÀQÇSÁS¾z°eŒG�A˜dÖ#¹zÑ#±€DÑJÙ#Ó3™t˜!¤s¨1£v°¡{—A�A™tÑ3€Lô ”Ô:¸DÓAÓB€Dô ”3�t“9ÖˆØ�GˆØ×Ñ˜l°ÐÓ6ˆØˆQ‹ñ ð
 *+×)?Ò)?ó IÑ)? AØ Ñ-ô  Ø12°Bµ¸,Ñ1F÷  ˜aÑ)?ñ I€AÔð
 	
€AØ
Œc�$‹iŒ-Ø�GˆØ��EˆØ”#�d“)ŒmØ×$Ñ$ T¥W×-Ò-Ø’Gà�Q•’Ø	ˆQ�Šà#Öùó9 KùÚ3ùòIs#   �1E4ÁE:Á,E:Ã	E?Ã$E?Ã4E?c                ó0  € V P                   P                  p\        \        V4      4       Fg  pW$,          pW0P                  V,          V P
                  V,          ,          ,          pV P                  V,          V P
                  V,          ,          pKi  	  V# )a\  
Parameters
==========

C: CosetTable
alpha: A live coset
w: A word in `A*`

Returns
=======

rho(tau(alpha), w)

Examples
========

>>> from sympy.combinatorics.fp_groups import FpGroup, CosetTable, define_schreier_generators, rewrite
>>> from sympy.combinatorics import free_group
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x**2, y**3, (x*y)**6])
>>> C = CosetTable(f, [])
>>> C.table = [[1, 1, 2, 3], [0, 0, 4, 5], [4, 4, 3, 0], [5, 5, 0, 2], [2, 2, 5, 1], [3, 3, 1, 4]]
>>> C.p = [0, 1, 2, 3, 4, 5]
>>> define_schreier_generators(C)
>>> rewrite(C, 0, (x*y)**6)
x_4*y_2*x_3*x_1*x_2*y_4*x_5

)r£  rF   r±   r   rÅ   r4  r{   )rY   ra  r#  ÚvrŸ   Úx_is   &&&   r   r³  r³  ¾  sl   € ð: 	
×Ñ×'Ñ'€AÜ”3�q“6Ž]ˆØ�dˆØ�c‰c�%�j˜Ÿ™ #�Õ'Õ'ˆØ—‘˜•˜qŸx™x¨�}Õ-Šñ ð €Hr   c           	     ó´  € V P                   pVP                  RR7       V P                  p\        \	        V4      ^,
          RR4       Få  pW,          p\        \	        V4      ^,
          RR4       F¹  pW%,          pVP                  V4      ^8X  g   K#  VP                  V4      pVP                  Wg,          4      pVP                  V^,           \	        V4      4      p	VP                  ^ V4      p
Wš,          RV,          ,          pW W% V Uu. uF  qDP                  Wk4      NK  	  pp Kã  	  Kç  	  Wn         W n        V P                  V P                   3# u upi )aÒ  
This technique eliminates one generator at a time. Heuristically this
seems superior in that we may select for elimination the generator with
shortest equivalent string at each stage.

>>> from sympy.combinatorics import free_group
>>> from sympy.combinatorics.fp_groups import FpGroup, coset_enumeration_r,             reidemeister_relators, define_schreier_generators, elimination_technique_2
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x**3, y**5, (x*y)**2]); H = [x*y, x**-1*y**-1*x*y*x]
>>> C = coset_enumeration_r(f, H)
>>> C.compress(); C.standardize()
>>> define_schreier_generators(C)
>>> reidemeister_relators(C)
>>> elimination_technique_2(C)
([y_1, y_2], [y_2**-3, y_2*y_1*y_2*y_1*y_2*y_1, y_1**2])

Tr–  rE   )
r¶  rŒ  r¤  r±   r   r©   r�   r†   r.  r‹  )rY   r)   rd   rŸ   r’   r>  r�   r›  rœ  r�  rž  Úrep_bys   &           r   Úelimination_technique_2r¾  ã  s+  € ð& ×#Ñ#€DØ‡I�I�d€IÔØ×!Ñ!€DÜ”3�t“9˜q•= " bÖ)ˆØ�gˆÜ”s˜4“y 1•} b¨"Ö-ˆAØ•'ˆCØ×"Ñ" 3Ó'¨1Ö,Ø×$Ñ$ SÓ)�ØŸI™I c¥fÓ-�	Ø—[‘[ ¨Q¥´°C³Ó9�Ø—[‘[  IÓ.�Ø�% 2 a¥4��Ø�GØ�GÙCGÓHÁ4¸C×*Ñ*¨3Ö7Á4�ÐHÚó .ñ *ð  $ÔØ!ÔØ×!Ñ! 1×#;Ñ#;Ð;Ð;ùò	 Is   ÄENc                óò  € V'       g   \        W4      pVP                  4        VP                  4        \        W#R7       \	        V4       VP
                  VP                  rT\        WERR7      w  rE\        V4      Vn	        \        V4      Vn        V'       dD   V Uu. uF  qbP                  \        V4      ,          NK   	  ppVP                  VP                  V3# VP                  VP                  3# u upi )aŒ  
Parameters
==========

fp_group: A finitely presented group, an instance of FpGroup
H: A subgroup whose presentation is to be found, given as a list
of words in generators of `fp_grp`
homomorphism: When set to True, return a homomorphism from the subgroup
                to the parent group

Examples
========

>>> from sympy.combinatorics import free_group
>>> from sympy.combinatorics.fp_groups import FpGroup, reidemeister_presentation
>>> F, x, y = free_group("x, y")

Example 5.6 Pg. 177 from [1]
>>> f = FpGroup(F, [x**3, y**5, (x*y)**2])
>>> H = [x*y, x**-1*y**-1*x*y*x]
>>> reidemeister_presentation(f, H)
((y_1, y_2), (y_1**2, y_2**3, y_2*y_1*y_2*y_1*y_2*y_1))

Example 5.8 Pg. 183 from [1]
>>> f = FpGroup(F, [x**3, y**3, (x*y)**3])
>>> H = [x*y, x*y**-1]
>>> reidemeister_presentation(f, H)
((x_0, y_0), (x_0**3, y_0**3, x_0*y_0*x_0*y_0*x_0*y_0))

Exercises Q2. Pg 187 from [1]
>>> f = FpGroup(F, [x**2*y**2, y**-1*x*y*x**-3])
>>> H = [x]
>>> reidemeister_presentation(f, H)
((x_0,), (x_0**4,))

Example 5.9 Pg. 183 from [1]
>>> f = FpGroup(F, [x**3*y**-3, (x*y)**3, (x*y**-1)**2])
>>> H = [x]
>>> reidemeister_presentation(f, H)
((x_0,), (x_0**6,))

r]   Tru  )r	   rp   rw   r¬  r¸  r¤  r¶  rx  r   Úschreier_generatorsr¥  rº   )Úfp_grprr   rY   rZ   rd   r)   r�   re   s   &&&&    r   rb   rb     sÉ   € ÷V Ü Ó*ˆØ‡J�J„L�!—-‘-”/Ü˜qÕ<Ü˜!ÔØ×'Ñ'¨×)AÑ)Aˆ$Ü& t¸tÔD�J€Dä! $›K€AÔÜ# D›k€AÔçÙ;?Ó@¹4°C×%Ñ%¤c¨#£h×/Ð/¹4ˆÐ@Ø×$Ñ$ a×&=Ñ&=¸uÐDÐDà× Ñ  !×"9Ñ"9Ð9Ð9ùò As   Â$C4)r(   rK  r  )2r  Úsympy.core.singletonr   Úsympy.core.symbolr   Úsympy.combinatorics.free_groupsr   r   r   Ú#sympy.combinatorics.rewritingsystemr   Úsympy.combinatorics.coset_tabler   r	   r
   rÁ   r   Úsympy.matrices.normalformsr   Úsympy.matricesr   Úsympy.polys.polytoolsr   Úsympy.printing.defaultsr   Úsympy.utilitiesr   Úsympy.utilities.magicr   Ú	itertoolsr   r   r    r&   r*   r   r  rY  rP  r_  rj  rx  r{  rz  r¬  r¸  r³  r¾  rb   r-   r(   r   r   Ú<module>rÎ     sö   ðÙ 4å "Ý %÷<ñ <å ?÷Bñ Bõ 1Ý 8Ý !Ý %Ý 3Ý "Ý )å ð ó7ó ð7ð ó.ó ð.ð
 ñó ðòôr&ˆoô r&ôjb�ô bôR6òr4ò8;ô.qðn6¨Uô 6òpNòb'ô\1%òf$òB"òJ&<ôP::ðz "‚r   