Ë
    7^(hœI  ã                   ó˜   — d dl Z d dlmZmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ  G d„ d	«      Zdd
„Zd„ Zd„ Zd„ Zdd„Zd„ Zy)é    N)ÚFpGroupÚ
FpSubgroupÚsimplify_presentation)Ú	FreeGroup)ÚPermutationGroup)Úigcd)Útotient)ÚSc                   ój   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚGroupHomomorphismzÖ
    A class representing group homomorphisms. Instantiate using `homomorphism()`.

    References
    ==========

    .. [1] Holt, D., Eick, B. and O'Brien, E. (2005). Handbook of computational group theory.

    c                 óX   — || _         || _        || _        d | _        d | _        d | _        y ©N)ÚdomainÚcodomainÚimagesÚ	_inversesÚ_kernelÚ_image)Úselfr   r   r   s       ú_/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/combinatorics/homomorphisms.pyÚ__init__zGroupHomomorphism.__init__   s,   € ØˆŒØ ˆŒØˆŒØˆŒØˆŒØˆ�ó    c                 ó:  — | j                  «       }i }t        | j                  j                  «       «      D ](  }| j                  |   }||v rŒ|j                  rŒ$|||<   Œ* t        | j                  t        «      r|j                  }n|j                  }|D ]‚  }||v s|j                  rŒ| j                  j                  }t        | j                  t        «      r|j                  |   ddd…   }n|}|D ]  }	|	|v r	|||	   z  }Œ|||	dz     dz  z  }Œ |||<   Œ„ |S )zÚ
        Return a dictionary with `{gen: inverse}` where `gen` is a rewriting
        generator of `codomain` (e.g. strong generator for permutation groups)
        and `inverse` is an element of its preimage

        Néÿÿÿÿ)ÚimageÚlistr   ÚkeysÚis_identityÚ
isinstancer   r   Ústrong_gensÚ
generatorsr   ÚidentityÚ_strong_gens_slp)
r   r   ÚinversesÚkÚvÚgensÚgÚwÚpartsÚss
             r   Ú_invszGroupHomomorphism._invs   s'  € ð —
‘
“ˆØˆÜ�d—k‘k×&Ñ&Ó(Ó)ò 	 ˆAØ—‘˜A‘ˆAØ˜’MØ—}“}Ø�˜’ð		 ô
 �d—m‘mÔ%5Ô6Ø×$Ñ$‰Dà×#Ñ#ˆDØò 	ˆAØ�H‰} §¢ØØ—‘×$Ñ$ˆAÜ˜$Ÿ-™-Ô)9Ô:Ø×.Ñ.¨qÑ1±$°B°$Ñ7‘à�Øò .�Ø˜‘=Ø˜( 1™+™‘Aà˜( 1 b¡5™/¨2Ñ-Ñ-‘Að	.ð
 ˆH�QŠKð	ð ˆr   c                 óÎ  — ddl m} ddlm} t	        |||f«      �rt	        | j
                  t        «      r| j
                  j                  |«      }| j                  €| j                  «       | _        | j                  «       }| j                  j                  }t	        | j
                  t        «      r|j                  |«      ddd…   }n|}t        t!        |«      «      D ]M  }||   }|j"                  rŒ|| j                  v r|| j                  |   z  }Œ6|| j                  |dz     dz  z  }ŒO |S t	        |t$        «      r|D �	cg c]  }	| j'                  |	«      ‘Œ c}	S yc c}	w )aÏ  
        Return an element of the preimage of ``g`` or of each element
        of ``g`` if ``g`` is a list.

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

        If the codomain is an FpGroup, the inverse for equal
        elements might not always be the same unless the FpGroup's
        rewriting system is confluent. However, making a system
        confluent can be time-consuming. If it's important, try
        `self.codomain.make_confluent()` first.

        r   ©ÚPermutation)ÚFreeGroupElementNr   )Úsympy.combinatoricsr/   Úsympy.combinatorics.free_groupsr0   r   r   r   Úreducer   r,   r   r   r"   r   Úgenerator_productÚrangeÚlenr   r   Úinvert)
r   r(   r/   r0   r   r)   r'   Úir+   Úes
             r   r7   zGroupHomomorphism.invert?   s4  € õ 	4ÝDÜ�a˜+Ð'7Ð8Õ9Ü˜$Ÿ-™-¬Ô1Ø—M‘M×(Ñ(¨Ó+�Ø�~‰~Ð%Ø!%§¡£�”Ø—J‘J“LˆEØ—‘×$Ñ$ˆAÜ˜$Ÿ-™-Ô)9Ô:Ø×.Ñ.¨qÓ1±$°B°$Ñ7‘à�ô œ3˜t›9Ó%ò 4�Ø˜‘G�Ø—=’=ØØ˜Ÿ™Ñ&Ø˜$Ÿ.™.¨Ñ+Ñ+‘Aà˜$Ÿ.™.¨¨B©Ñ/°Ñ3Ñ3‘Að4ð ˆHÜ˜œ4Ô Ø,-Ö. q�D—K‘K •NÒ.Ð.ð !ùÚ.s   ÅE"c                 ó\   — | j                   €| j                  «       | _         | j                   S )z0
        Compute the kernel of `self`.

        )r   Ú_compute_kernel©r   s    r   ÚkernelzGroupHomomorphism.kernelm   s(   € ð
 �<‰<ÐØ×/Ñ/Ó1ˆDŒLØ�|‰|Ðr   c                 óR  — | j                   }|j                  «       }|t        j                  u rt	        d«      ‚g }t        |t        «      rt        |j                  «      }nt        ||d¬«      }| j                  «       j                  «       }|j                  «       |z  |k7  rƒ|j                  «       }|| j                   | |«      «      dz  z  }||vr;|j                  |«       t        |t        «      rt        |«      }nt        ||d¬«      }|j                  «       |z  |k7  rŒƒ|S )Nz9Kernel computation is not implemented for infinite groupsT)Únormalr   )r   Úorderr
   ÚInfinityÚNotImplementedErrorr   r   r"   r   r   Úrandomr7   Úappend)r   ÚGÚG_orderr'   ÚKr8   Úrr%   s           r   r;   z!GroupHomomorphism._compute_kernelv   sý   € Ø�K‰KˆØ—'‘'“)ˆØ”a—j‘jÑ Ü%ØKóMð MàˆÜ�aÔ)Ô*Ü  §¡Ó,‰Aä˜1˜d¨4Ô0ˆAØ�J‰J‹L×ÑÓ ˆØ�g‰g‹i˜‰k˜WÒ$Ø—‘“
ˆAØ�$—+‘+™d 1›gÓ&¨Ñ*Ñ*ˆAØ˜‰zØ—‘˜A”Ü˜aÔ!1Ô2Ü(¨Ó.‘Aä" 1 d°4Ô8�Að �g‰g‹i˜‰k˜WÓ$ð ˆr   c                 óL  — | j                   €�t        t        | j                  j	                  «       «      «      }t        | j                  t        «      r,| j                  j                  |«      | _         | j                   S t        | j                  |«      | _         | j                   S )z/
        Compute the image of `self`.

        )
r   r   Úsetr   Úvaluesr   r   r   Úsubgroupr   )r   rK   s     r   r   zGroupHomomorphism.image�   sy   € ð
 �;‰;ÐÜœ#˜dŸk™k×0Ñ0Ó2Ó3Ó4ˆFÜ˜$Ÿ-™-Ô)9Ô:Ø"Ÿm™m×4Ñ4°VÓ<�”ð �{‰{Ðô )¨¯©¸Ó?�”Ø�{‰{Ðr   c                 ó‚  — || j                   vr@t        |t        t        f«      r|D �cg c]  }| j	                  |«      ‘Œ c}S t        d«      ‚|j                  r| j                  j                  S | j                  }| j                  j                  }t        | j                   t        «      rK| j                   j                  |d¬«      }|D ]'  }|| j                  v r	||   |z  }Œ||dz     dz  |z  }Œ) |S d}|j                  D ]1  \  }}	|	dk  r	||   dz  }n||   }|||   |	z  z  }|t        |	«      z  }Œ3 |S c c}w )z*
        Apply `self` to `elem`.

        z2The supplied element does not belong to the domainT)Úoriginalr   r   )r   r   r   ÚtupleÚ_applyÚ
ValueErrorr   r   r"   r   r   r4   Ú
array_formÚabs)
r   Úelemr9   r   Úvaluer'   r(   r8   Ú_Úps
             r   rP   zGroupHomomorphism._applyš   sH  € ð
 �t—{‘{Ñ"Ü˜$¤¤u Ô.Ø04Ö5¨1˜Ÿ™ A�Ò5Ð5ÜÐQÓRÐRØ×ÒØ—=‘=×)Ñ)Ð)à—[‘[ˆFØ—M‘M×*Ñ*ˆEÜ˜$Ÿ+™+Ô'7Ô8Ø—{‘{×4Ñ4°TÀDÐ4ÓI�Øò 8�AØ˜DŸK™KÑ'Ø & q¡	¨%¡™à & q¨"¡u¡¨rÑ 1°%Ñ 7™ð	8ð ˆð �Ø ŸO™Oò  ‘D�A�qØ˜1’uØ  ™G R™K™à  ™G˜Ø! &¨¡)¨Q¡,Ñ.�EØœ˜Q›‘K‘Að ð ˆùò/ 6s   ©D<c                 ó$   — | j                  |«      S r   )rP   )r   rT   s     r   Ú__call__zGroupHomomorphism.__call__º   s   € Ø�{‰{˜4Ó Ð r   c                 óD   — | j                  «       j                  «       dk(  S )z9
        Check if the homomorphism is injective

        é   )r=   r@   r<   s    r   Úis_injectivezGroupHomomorphism.is_injective½   s   € ð
 �{‰{‹}×"Ñ"Ó$¨Ñ)Ð)r   c                 óÆ   — | j                  «       j                  «       }| j                  j                  «       }|t        j                  u r|t        j                  u ry||k(  S )z:
        Check if the homomorphism is surjective

        N)r   r@   r   r
   rA   )r   ÚimÚoths      r   Úis_surjectivezGroupHomomorphism.is_surjectiveÄ   sN   € ð
 �Z‰Z‹\×ÑÓ!ˆØ�m‰m×!Ñ!Ó#ˆØ”—‘Ñ ¤q§z¡zÑ 1Øà˜‘9Ðr   c                 óF   — | j                  «       xr | j                  «       S )z5
        Check if `self` is an isomorphism.

        )r\   r`   r<   s    r   Úis_isomorphismz GroupHomomorphism.is_isomorphismÐ   s!   € ð
 × Ñ Ó"Ò; t×'9Ñ'9Ó';Ð;r   c                 óD   — | j                  «       j                  «       dk(  S )zs
        Check is `self` is a trivial homomorphism, i.e. all elements
        are mapped to the identity.

        r[   )r   r@   r<   s    r   Ú
is_trivialzGroupHomomorphism.is_trivial×   s   € ð �z‰z‹|×!Ñ!Ó# qÑ(Ð(r   c           	      ó  — |j                  «       j                  | j                  «      st        d«      ‚|j                  D �ci c]  }| |  ||«      «      “Œ }}t        |j                  | j                  |«      S c c}w )z°
        Return the composition of `self` and `other`, i.e.
        the homomorphism phi such that for all g in the domain
        of `other`, phi(g) = self(other(g))

        z?The image of `other` must be a subgroup of the domain of `self`)r   Úis_subgroupr   rQ   r   r   r   )r   Úotherr(   r   s       r   ÚcomposezGroupHomomorphism.composeß   sn   € ð �{‰{‹}×(Ñ(¨¯©Ô5Üð +ó ,ð ,à-2¯\©\Ö:¨�!‘T™% ›(“^Ñ#Ð:ˆÐ:Ü  §¡¨t¯}©}¸fÓEÐEùò ;s   ÁA<c                 óê   — t        |t        «      r|j                  | j                  «      st	        d«      ‚|}|j
                  D �ci c]  }| | |«      “Œ }}t        || j                  |«      S c c}w )zh
        Return the restriction of the homomorphism to the subgroup `H`
        of the domain.

        z'Given H is not a subgroup of the domain)r   r   rf   r   rQ   r!   r   r   )r   ÚHr   r(   r   s        r   Úrestrict_tozGroupHomomorphism.restrict_toì   sf   € ô ˜!Ô-Ô.°a·m±mÀDÇKÁKÔ6PÜÐFÓGÐGØˆØ&'§l¡lÖ3 �!‘T˜!“W‘*Ð3ˆÐ3Ü  ¨¯©¸Ó?Ð?ùò 4s   ÁA0c                 ó´  — |j                  | j                  «       «      st        d«      ‚g }t        | j                  «       j                  «      }|j
                  D ]y  }| j                  |«      }||vr|j                  |«       t        |«      }| j                  «       j
                  D ])  }||z  |vsŒ|j                  ||z  «       t        |«      }Œ+ Œ{ |S )z†
        Return the subgroup of the domain that is the inverse image
        of the subgroup ``H`` of the homomorphism image

        z&Given H is not a subgroup of the image)	rf   r   rQ   r   r"   r!   r7   rD   r=   )r   rj   r'   ÚPÚhÚh_ir%   s          r   Úinvert_subgroupz!GroupHomomorphism.invert_subgroupø   sÁ   € ð �}‰}˜TŸZ™Z›\Ô*ÜÐEÓFÐFØˆÜ˜TŸZ™Z›\×2Ñ2Ó3ˆØ—‘ò 	/ˆAØ—+‘+˜a“.ˆCØ˜!‰|Ø—‘˜CÔ Ü$ TÓ*�Ø—[‘[“]×-Ñ-ò /�Ø�S‘5 ’>Ø—K‘K  #¡Ô&Ü(¨Ó.‘Añ/ð	/ð ˆr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r,   r7   r=   r;   r   rP   rY   r\   r`   rb   rd   rh   rk   rp   © r   r   r   r   	   sW   „ ñòò!òF,/ò\òò.òò@!ò*ò
ò<ò)òFò
@ór   r   c                 óØ  ‡‡— t        | t        t        t        f«      st	        d«      ‚t        ‰t        t        t        f«      st	        d«      ‚| j
                  Št        ˆfd„|D «       «      st        d«      ‚t        ˆfd„|D «       «      st        d«      ‚|r"t        |«      t        |«      k7  rt        d«      ‚t        |«      }t        |«      }|j                  ‰j                  gt        ‰«      t        |«      z
  z  «       |j                  ‰D �cg c]	  }||vsŒ|‘Œ c}«       t        t        ||«      «      }|rt        | ‰|«      st        d«      ‚t        | ‰|«      S c c}w )	aŠ  
    Create (if possible) a group homomorphism from the group ``domain``
    to the group ``codomain`` defined by the images of the domain's
    generators ``gens``. ``gens`` and ``images`` can be either lists or tuples
    of equal sizes. If ``gens`` is a proper subset of the group's generators,
    the unspecified generators will be mapped to the identity. If the
    images are not specified, a trivial homomorphism will be created.

    If the given images of the generators do not define a homomorphism,
    an exception is raised.

    If ``check`` is ``False``, do not check whether the given images actually
    define a homomorphism.

    zThe domain must be a groupzThe codomain must be a groupc              3   ó&   •K  — | ]  }|‰v –— Œ
 y ­wr   ru   )Ú.0r(   r!   s     €r   ú	<genexpr>zhomomorphism.<locals>.<genexpr>#  s   øè ø€ Ò- 1ˆq�JŒÑ-ùó   ƒzCThe supplied generators must be a subset of the domain's generatorsc              3   ó&   •K  — | ]  }|‰v –— Œ
 y ­wr   ru   )rx   r(   r   s     €r   ry   zhomomorphism.<locals>.<genexpr>%  s   øè ø€ Ò- ˆq�HŒ}Ñ-ùrz   z+The images must be elements of the codomainz>The number of images must be equal to the number of generatorsz-The given images do not define a homomorphism)r   r   r   r   Ú	TypeErrorr!   ÚallrQ   r6   r   Úextendr"   ÚdictÚzipÚ_check_homomorphismr   )r   r   r'   r   Úcheckr(   r!   s    `    @r   Úhomomorphismrƒ     s4  ù€ ô  �fÔ/´¼)ÐDÔEÜÐ4Ó5Ð5Ü�hÔ!1´7¼IÐ FÔGÜÐ6Ó7Ð7à×"Ñ"€JÜÓ-¨Ô-Ô-ÜÐ^Ó_Ð_ÜÓ- fÔ-Ô-ÜÐFÓGÐGá”#�f“+¤ T£Ò*ÜÐYÓZÐZä�‹:€DÜ�&‹\€Fà
‡M�M�8×$Ñ$Ð%¤s¨:£´s¸6³{Ñ'BÑCÔDØ‡K�K˜JÖ8�q¨!°4ª-’Ò8Ô9Ü”#�d˜6Ó"Ó#€FáÔ(¨°¸6ÔBÜÐHÓIÐIÜ˜V X¨vÓ6Ð6ùò 9s   Ä	E'Ä E'c                 ó  ‡‡‡— t        | d«      r| n| j                  «       }|j                  }|j                  }|D �cg c]  }|j                  d   ‘Œ }}t        t        || j                  «      «      Š|j                  Šˆˆˆfd„}|D ]y  }	t        |t        «      rQ|j                   ||	«      ‰«      }
|
€I|j                  «       }|j                   ||	«      ‰«      }
|
€|st        d«      ‚ ||	«      j                  }
|
rŒy y yc c}w )a]  
    Check that a given mapping of generators to images defines a homomorphism.

    Parameters
    ==========
    domain : PermutationGroup, FpGroup, FreeGroup
    codomain : PermutationGroup, FpGroup, FreeGroup
    images : dict
        The set of keys must be equal to domain.generators.
        The values must be elements of the codomain.

    Úrelatorsr   c                 óT   •— ‰}| j                   D ]  \  }}‰|   }|‰|   |z  z  }Œ |S r   )rR   )rH   r)   ÚsymbolÚpowerr(   r"   r   Úsymbols_to_domain_generatorss        €€€r   r   z#_check_homomorphism.<locals>._imageJ  sC   ø€ ØˆØŸ\™\ò 	"‰MˆF�EØ,¨VÑ4ˆAØ�˜‘˜EÑ!Ñ!‰Að	"ð ˆr   zÖCan't determine if the images define a homomorphism. Try increasing the maximum number of rewriting rules (group._rewriting_system.set_max(new_value); the current value is stored in group._rewriting_system.maxeqns)FT)ÚhasattrÚpresentationr…   r!   Úext_repr   r€   r"   r   r   ÚequalsÚmake_confluentÚRuntimeErrorr   )r   r   r   ÚpresÚrelsr'   r(   Úsymbolsr   rH   r+   Úsuccessr"   r‰   s     `         @@r   r�   r�   6  s  ú€ ô ˜V ZÔ0‰6°f×6IÑ6IÓ6K€DØ�=‰=€DØ�?‰?€DØ%)Ö* ˆq�y‰y˜‹|Ð*€GÐ*Ü#'¬¨G°V×5FÑ5FÓ(GÓ#HÐ Ø× Ñ €Höð ò ˆÜ�h¤Ô(Ø—‘¡ q£	¨8Ó4ˆAØˆyð #×1Ñ1Ó3�Ø—O‘O¡F¨1£I¨xÓ8�Ø�9¡WÜ&ð (+ó ,ð ,ñ �q“	×%Ñ%ˆAÚÙð'ð( ùò? +s   ¾Dc                 ó  — ddl m} ddlm}  |t	        |«      «      }|j
                  }t        |«      }| j                  D ��ci c].  }|| ||D �cg c]  }|j                  ||z  «      ‘Œ c}«      z  “Œ0 }}}| j                  |¬«       t        | ||«      }	t	        | j                  «      t	        |«      kD  r| j                  t	        |«         |	_        |	S t        | j
                  g«      |	_        |	S c c}w c c}}w )z•
    Return the homomorphism induced by the action of the permutation
    group ``group`` on the set ``omega`` that is closed under the action.

    r   r.   ©ÚSymmetricGroup)Úbase)r1   r/   Ú sympy.combinatorics.named_groupsr–   r6   r"   r   r!   ÚindexÚ_schreier_simsr   Úbasic_stabilizersr   r   )
ÚgroupÚomegar/   r–   r   r"   r(   Úor   rj   s
             r   Úorbit_homomorphismrŸ   g  sâ   € õ 0Ý?Ùœc %›jÓ)€HØ× Ñ €HÜ�‹K€EØRW×RbÑRb×cÈQˆa�™+ÀÖ&G¸A u§{¡{°1°Q±3Õ'7Ò&GÓHÑHÑHÐc€FÑcØ	×Ñ˜eÐÔ$Ü˜% ¨6Ó2€AÜ
ˆ5×"Ñ"Ó#¤c¨%£jÒ0Ø×+Ñ+¬C°«JÑ7ˆŒ	ð €Hô % e§n¡nÐ%5Ó6ˆŒ	Ø€Hùò 'HùÓcs   ÁC;ÁC6Á,C;Ã6C;c                 ó®  — ddl m} ddlm} t	        |«      }d}g }dg|z  }t        |«      D ]&  }||   |k(  sŒ|j                  |«       |||<   |dz  }Œ( t        |«      D ]  }|||      ||<   Œ  ||«      }	t        |«      }
| j                  D ��ci c]"  }| ||
D �cg c]  }|||   |z     ‘Œ c}«      “Œ$ }}}t        | |	|«      }|S c c}w c c}}w )ab  
    Return the homomorphism induced by the action of the permutation
    group ``group`` on the block system ``blocks``. The latter should be
    of the same form as returned by the ``minimal_block`` method for
    permutation groups, namely a list of length ``group.degree`` where
    the i-th entry is a representative of the block i belongs to.

    r   r.   r•   Nr[   )	r1   r/   r˜   r–   r6   r5   rD   r!   r   )rœ   Úblocksr/   r–   ÚnÚmrW   Úbr8   r   r"   r(   r   rj   s                 r   Úblock_homomorphismr¥   {  sõ   € õ 0Ý?äˆF‹€Að 	
€AØ
€AØ	ˆˆq‰€AÜ�1‹Xò ˆØ�!‰9˜‹>Ø�H‰H�QŒKØˆAˆa‰DØ�‰F‰Að	ô
 �1‹Xò ˆØ�˜‘‰|ˆˆ!Šðñ ˜aÓ €Hä�Q‹x€HØEJ×EUÑEU×VÀˆa‘°Ö:¨A˜a  !¡ Q¡›iÒ:Ó;Ñ;ÐV€FÑVÜ˜% ¨6Ó2€AØ€Hùò ;ùÓVs   ÂCÂCÂ1	CÃCc                 óT  — t        | t        t        f«      st        d«      ‚t        |t        t        f«      st        d«      ‚t        | t        «      r›t        |t        «      r‹t	        | «      } t	        |«      }| j
                  |j
                  k(  r\| j                  j                  «       |j                  j                  «       k(  r'|sydt        | || j
                  |j
                  «      fS |}| j                  «       }|j                  «       }|t        j                  u rt        d«      ‚t        |t        «      r0|t        j                  u rt        d«      ‚|j                  «       \  }}||k7  s| j                  |j                  k7  r|syy|s|}t        |t!        |«      «      dk(  ryt#        | j
                  «      }t%        j&                  |t)        |«      «      D ]Ã  }	t#        |	«      }
|
j+                  |j,                  gt)        | j
                  «      t)        |
«      z
  z  «       t/        t1        ||
«      «      }t3        | ||«      sŒot        |t        «      rj5                  |
«      }
t        | || j
                  |
d¬«      }|j7                  «       sŒ»|s yd|fc S  |syy)aE  
    Compute an isomorphism between 2 given groups.

    Parameters
    ==========

    G : A finite ``FpGroup`` or a ``PermutationGroup``.
        First group.

    H : A finite ``FpGroup`` or a ``PermutationGroup``
        Second group.

    isomorphism : bool
        This is used to avoid the computation of homomorphism
        when the user only wants to check if there exists
        an isomorphism between the groups.

    Returns
    =======

    If isomorphism = False -- Returns a boolean.
    If isomorphism = True  -- Returns a boolean and an isomorphism between `G` and `H`.

    Examples
    ========

    >>> from sympy.combinatorics import free_group, Permutation
    >>> from sympy.combinatorics.perm_groups import PermutationGroup
    >>> from sympy.combinatorics.fp_groups import FpGroup
    >>> from sympy.combinatorics.homomorphisms import group_isomorphism
    >>> from sympy.combinatorics.named_groups import DihedralGroup, AlternatingGroup

    >>> D = DihedralGroup(8)
    >>> p = Permutation(0, 1, 2, 3, 4, 5, 6, 7)
    >>> P = PermutationGroup(p)
    >>> group_isomorphism(D, P)
    (False, None)

    >>> F, a, b = free_group("a, b")
    >>> G = FpGroup(F, [a**3, b**3, (a*b)**2])
    >>> H = AlternatingGroup(4)
    >>> (check, T) = group_isomorphism(G, H)
    >>> check
    True
    >>> T(b*a*b**-1*a**-1*b**-1)
    (0 2 3)

    Notes
    =====

    Uses the approach suggested by Robert Tarjan to compute the isomorphism between two groups.
    First, the generators of ``G`` are mapped to the elements of ``H`` and
    we check if the mapping induces an isomorphism.

    z2The group must be a PermutationGroup or an FpGroupTz<Isomorphism methods are not implemented for infinite groups.F)FNr[   )r‚   )r   r   r   r|   r   r!   r…   Úsortrƒ   r@   r
   rA   rB   Ú_to_perm_groupÚ
is_abelianr   r	   r   Ú	itertoolsÚpermutationsr6   r~   r"   r   r€   r�   r7   rb   )rE   rj   ÚisomorphismÚ_HÚg_orderÚh_orderÚh_isomorphismr¢   r'   Úsubsetr   Ú_imagesÚTs                r   Úgroup_isomorphismr´   Ÿ  s;  € ôp �aÔ*¬GÐ4Ô5ÜÐLÓMÐMÜ�aÔ*¬GÐ4Ô5ÜÐLÓMÐMä�!”WÔ¤*¨Q´Ô"8Ü! !Ó$ˆÜ! !Ó$ˆð �<‰<˜1Ÿ<™<Ò'¨Q¯Z©Z×,=Ñ,=Ó,?ÀAÇJÁJ×CTÑCTÓCVÒ,VÙØØœ, q¨!¨Q¯\©\¸1¿<¹<ÓHÐIÐIð 
€BØ�g‰g‹i€GØ�g‰g‹i€Gà”!—*‘*ÑÜ!Ð"`ÓaÐaä�!”WÔØ”a—j‘jÑ Ü%Ð&dÓeÐeØ×,Ñ,Ó.ÑˆˆMà�7Ò §¡°·±Ò <ÙØØáð ˆÜ�”G˜A“JÓ AÒ%Øô �—‘Ó€DÜ×(Ñ(¨¬S°«YÓ7ò !ˆÜ�f“ˆØ�‰�r—{‘{�m¤S¨¯©Ó%6´s¸6³{Ñ%BÑCÔDÜ”s˜4 Ó'Ó(ˆÜ˜q " gÕ.Ü˜!œWÔ%Ø&×-Ñ-¨fÓ5�Ü˜a  A§L¡L°&ÀÔFˆAØ×ÑÕ!á"ÙØ˜a�yÒ ð!ñ ØØr   c                 ó   — t        | |d¬«      S )a  
    Check if the groups are isomorphic to each other

    Parameters
    ==========

    G : A finite ``FpGroup`` or a ``PermutationGroup``
        First group.

    H : A finite ``FpGroup`` or a ``PermutationGroup``
        Second group.

    Returns
    =======

    boolean
    F)r¬   )r´   )rE   rj   s     r   Úis_isomorphicr¶     s   € ô$ ˜Q ¨uÔ5Ð5r   )ru   T)T)rª   Úsympy.combinatorics.fp_groupsr   r   r   r2   r   Úsympy.combinatorics.perm_groupsr   Úsympy.core.intfuncr   Ú%sympy.functions.combinatorial.numbersr	   Úsympy.core.singletonr
   r   rƒ   r�   rŸ   r¥   r´   r¶   ru   r   r   ú<module>r¼      sM   ðÛ ß TÑ TÝ 5Ý <Ý #Ý 9Ý "÷Bñ BóH'7òR/òbò("óHróh6r   