ó
    Š*£h±U  ã                   óŒ   • S r SSKJrJrJrJrJr  SSKJr   " S S5      r	 " S S\	5      r
 " S S	\
5      r " S
 S\
5      rS rg)a   
Computations with homomorphisms of modules and rings.

This module implements classes for representing homomorphisms of rings and
their modules. Instead of instantiating the classes directly, you should use
the function ``homomorphism(from, to, matrix)`` to create homomorphism objects.
é    )ÚModuleÚ
FreeModuleÚQuotientModuleÚ	SubModuleÚSubQuotientModule)ÚCoercionFailedc                   óÊ   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS r\rS rS rS rS rS rS rS r S r!S r"S r#g!)"ÚModuleHomomorphismé   a²  
Abstract base class for module homomoprhisms. Do not instantiate.

Instead, use the ``homomorphism`` function:

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> homomorphism(F, F, [[1, 0], [0, 1]])
Matrix([
[1, 0], : QQ[x]**2 -> QQ[x]**2
[0, 1]])

Attributes:

- ring - the ring over which we are considering modules
- domain - the domain module
- codomain - the codomain module
- _ker - cached kernel
- _img - cached image

Non-implemented methods:

- _kernel
- _image
- _restrict_domain
- _restrict_codomain
- _quotient_domain
- _quotient_codomain
- _apply
- _mul_scalar
- _compose
- _add
c                 ó@  • [        U[        5      (       d  [        SU-  5      e[        U[        5      (       d  [        SU-  5      eUR                  UR                  :w  a  [	        SU< SU< 35      eXl        X l        UR                  U l        S U l        S U l        g )NzSource must be a module, got %szTarget must be a module, got %sz0Source and codomain must be over same ring, got z != )	Ú
isinstancer   Ú	TypeErrorÚringÚ
ValueErrorÚdomainÚcodomainÚ_kerÚ_img)Úselfr   r   s      Ú[/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/polys/agca/homomorphisms.pyÚ__init__ÚModuleHomomorphism.__init__8   s‹   € Ü˜&¤&×)Ñ)ÜÐ=ÀÑFÓGÐGÜ˜(¤F×+Ñ+ÜÐ=ÀÑHÓIÐIØ�;‰;˜(Ÿ-™-Ó'ÝÛ/5²xðAó Bð BàŒØ ŒØ—K‘KˆŒ	ØˆŒ	Øˆ�	ó    c                 ó^   • U R                   c  U R                  5       U l         U R                   $ )aŽ  
Compute the kernel of ``self``.

That is, if ``self`` is the homomorphism `\phi: M \to N`, then compute
`ker(\phi) = \{x \in M | \phi(x) = 0\}`.  This is a submodule of `M`.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> homomorphism(F, F, [[1, 0], [x, 0]]).kernel()
<[x, -1]>
)r   Ú_kernel©r   s    r   ÚkernelÚModuleHomomorphism.kernelF   s%   € ð$ �9‰9ÑØŸ™›ˆDŒIØ�y‰yÐr   c                 ó^   • U R                   c  U R                  5       U l         U R                   $ )aš  
Compute the image of ``self``.

That is, if ``self`` is the homomorphism `\phi: M \to N`, then compute
`im(\phi) = \{\phi(x) | x \in M \}`.  This is a submodule of `N`.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> homomorphism(F, F, [[1, 0], [x, 0]]).image() == F.submodule([1, 0])
True
)r   Ú_imager   s    r   ÚimageÚModuleHomomorphism.image\   s%   € ð$ �9‰9ÑØŸ™›ˆDŒIØ�y‰yÐr   c                 ó   • [         e)zCompute the kernel of ``self``.©ÚNotImplementedErrorr   s    r   r   ÚModuleHomomorphism._kernelr   ó   € ä!Ð!r   c                 ó   • [         e)zCompute the image of ``self``.r$   r   s    r   r    ÚModuleHomomorphism._imagev   r'   r   c                 ó   • [         e©z%Implementation of domain restriction.r$   ©r   Úsms     r   Ú_restrict_domainÚ#ModuleHomomorphism._restrict_domainz   r'   r   c                 ó   • [         e©z'Implementation of codomain restriction.r$   r,   s     r   Ú_restrict_codomainÚ%ModuleHomomorphism._restrict_codomain~   r'   r   c                 ó   • [         e©z"Implementation of domain quotient.r$   r,   s     r   Ú_quotient_domainÚ#ModuleHomomorphism._quotient_domain‚   r'   r   c                 ó   • [         e©z$Implementation of codomain quotient.r$   r,   s     r   Ú_quotient_codomainÚ%ModuleHomomorphism._quotient_codomain†   r'   r   c                 óÀ   • U R                   R                  U5      (       d  [        SU R                   < SU< 35      eXR                   :X  a  U $ U R                  U5      $ )a  
Return ``self``, with the domain restricted to ``sm``.

Here ``sm`` has to be a submodule of ``self.domain``.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> h = homomorphism(F, F, [[1, 0], [x, 0]])
>>> h
Matrix([
[1, x], : QQ[x]**2 -> QQ[x]**2
[0, 0]])
>>> h.restrict_domain(F.submodule([1, 0]))
Matrix([
[1, x], : <[1, 0]> -> QQ[x]**2
[0, 0]])

This is the same as just composing on the right with the submodule
inclusion:

>>> h * F.submodule([1, 0]).inclusion_hom()
Matrix([
[1, x], : <[1, 0]> -> QQ[x]**2
[0, 0]])
zsm must be a submodule of ú, got )r   Úis_submoduler   r.   r,   s     r   Úrestrict_domainÚ"ModuleHomomorphism.restrict_domainŠ   sU   € ð@ �{‰{×'Ñ'¨×+Ñ+ÝØ $§¤ªRð1ó 2ð 2à—‘ÓØˆKØ×$Ñ$ RÓ(Ð(r   c                 óÐ   • UR                  U R                  5       5      (       d!  [        SU R                  5       < SU< 35      eXR                  :X  a  U $ U R	                  U5      $ )aì  
Return ``self``, with codomain restricted to to ``sm``.

Here ``sm`` has to be a submodule of ``self.codomain`` containing the
image.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> h = homomorphism(F, F, [[1, 0], [x, 0]])
>>> h
Matrix([
[1, x], : QQ[x]**2 -> QQ[x]**2
[0, 0]])
>>> h.restrict_codomain(F.submodule([1, 0]))
Matrix([
[1, x], : QQ[x]**2 -> <[1, 0]>
[0, 0]])
z
the image ú must contain sm, got )r>   r!   r   r   r2   r,   s     r   Úrestrict_codomainÚ$ModuleHomomorphism.restrict_codomain±   sV   € ð2 �‰˜tŸz™z›|×,Ñ,ÝØ $§
¡
¦ªbð2ó 3ð 3à—‘ÓØˆKØ×&Ñ& rÓ*Ð*r   c                 óÜ   • U R                  5       R                  U5      (       d!  [        SU R                  5       < SU< 35      eUR                  5       (       a  U $ U R	                  U5      $ )aÝ  
Return ``self`` with domain replaced by ``domain/sm``.

Here ``sm`` must be a submodule of ``self.kernel()``.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> h = homomorphism(F, F, [[1, 0], [x, 0]])
>>> h
Matrix([
[1, x], : QQ[x]**2 -> QQ[x]**2
[0, 0]])
>>> h.quotient_domain(F.submodule([-x, 1]))
Matrix([
[1, x], : QQ[x]**2/<[-x, 1]> -> QQ[x]**2
[0, 0]])
zkernel rB   )r   r>   r   Úis_zeror6   r,   s     r   Úquotient_domainÚ"ModuleHomomorphism.quotient_domainÑ   sY   € ð0 �{‰{‹}×)Ñ)¨"×-Ñ-ÝØ"Ÿk™kžmªRð1ó 2ð 2à�:‰:�<‰<ØˆKØ×$Ñ$ RÓ(Ð(r   c                 óÌ   • U R                   R                  U5      (       d  [        SU R                   < SU< 35      eUR                  5       (       a  U $ U R	                  U5      $ )a‚  
Return ``self`` with codomain replaced by ``codomain/sm``.

Here ``sm`` must be a submodule of ``self.codomain``.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> h = homomorphism(F, F, [[1, 0], [x, 0]])
>>> h
Matrix([
[1, x], : QQ[x]**2 -> QQ[x]**2
[0, 0]])
>>> h.quotient_codomain(F.submodule([1, 1]))
Matrix([
[1, x], : QQ[x]**2 -> QQ[x]**2/<[1, 1]>
[0, 0]])

This is the same as composing with the quotient map on the left:

>>> (F/[(1, 1)]).quotient_hom() * h
Matrix([
[1, x], : QQ[x]**2 -> QQ[x]**2/<[1, 1]>
[0, 0]])
z#sm must be a submodule of codomain r=   )r   r>   r   rF   r:   r,   s     r   Úquotient_codomainÚ$ModuleHomomorphism.quotient_codomainð   sU   € ð> �}‰}×)Ñ)¨"×-Ñ-ÝØ $§¤ªrð3ó 4ð 4à�:‰:�<‰<ØˆKØ×&Ñ& rÓ*Ð*r   c                 ó   • [         e)zApply ``self`` to ``elem``.r$   ©r   Úelems     r   Ú_applyÚModuleHomomorphism._apply  r'   r   c                 óˆ   • U R                   R                  U R                  U R                  R                  U5      5      5      $ ©N)r   ÚconvertrO   r   rM   s     r   Ú__call__ÚModuleHomomorphism.__call__  s/   € Ø�}‰}×$Ñ$ T§[¡[°·±×1DÑ1DÀTÓ1JÓ%KÓLÐLr   c                 ó   • [         e)zá
Compose ``self`` with ``oth``, that is, return the homomorphism
obtained by first applying then ``self``, then ``oth``.

(This method is private since in this syntax, it is non-obvious which
homomorphism is executed first.)
r$   ©r   Úoths     r   Ú_composeÚModuleHomomorphism._compose  s
   € ô "Ð!r   c                 ó   • [         e)z8Scalar multiplication. ``c`` is guaranteed in self.ring.r$   )r   Úcs     r   Ú_mul_scalarÚModuleHomomorphism._mul_scalar'  r'   r   c                 ó   • [         e)z^
Homomorphism addition.
``oth`` is guaranteed to be a homomorphism with same domain/codomain.
r$   rW   s     r   Ú_addÚModuleHomomorphism._add+  s
   € ô
 "Ð!r   c                 ó    • [        U[        5      (       d  gUR                  U R                  :H  =(       a    UR                  U R                  :H  $ )zEHelper to check that oth is a homomorphism with same domain/codomain.F)r   r
   r   r   rW   s     r   Ú
_check_homÚModuleHomomorphism._check_hom2  s8   € ä˜#Ô1×2Ñ2ØØ�z‰z˜TŸ[™[Ñ(×J¨S¯\©\¸T¿]¹]Ñ-JÐJr   c                 ó  • [        U[        5      (       a+  U R                  UR                  :X  a  UR	                  U 5      $  U R                  U R                  R                  U5      5      $ ! [         a	    [        s $ f = frR   )
r   r
   r   r   rY   r]   r   rS   r   ÚNotImplementedrW   s     r   Ú__mul__ÚModuleHomomorphism.__mul__8  sh   € Ü�cÔ-×.Ñ.°4·;±;À#Ç,Á,Ó3NØ—<‘< Ó%Ð%ð	"Ø×#Ñ# D§I¡I×$5Ñ$5°cÓ$:Ó;Ð;øÜó 	"Ü!Ò!ð	"ús   Á)A, Á,A?Á>A?c                 óŠ   •  U R                  SU R                  R                  U5      -  5      $ ! [         a	    [        s $ f = f)Né   )r]   r   rS   r   rf   rW   s     r   Ú__truediv__ÚModuleHomomorphism.__truediv__C  sA   € ð	"Ø×#Ñ# A d§i¡i×&7Ñ&7¸Ó&<Ñ$<Ó=Ð=øÜó 	"Ü!Ò!ð	"ús   ‚,/ ¯AÁAc                 ó\   • U R                  U5      (       a  U R                  U5      $ [        $ rR   )rc   r`   rf   rW   s     r   Ú__add__ÚModuleHomomorphism.__add__I  s%   € Ø�?‰?˜3×ÑØ—9‘9˜S“>Ð!ÜÐr   c                 ó¬   • U R                  U5      (       a9  U R                  UR                  U R                  R	                  S5      5      5      $ [
        $ )Néÿÿÿÿ)rc   r`   r]   r   rS   rf   rW   s     r   Ú__sub__ÚModuleHomomorphism.__sub__N  s>   € Ø�?‰?˜3×ÑØ—9‘9˜SŸ_™_¨T¯Y©Y×->Ñ->¸rÓ-BÓCÓDÐDÜÐr   c                 ó>   • U R                  5       R                  5       $ )aŸ  
Return True if ``self`` is injective.

That is, check if the elements of the domain are mapped to the same
codomain element.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> h = homomorphism(F, F, [[1, 0], [x, 0]])
>>> h.is_injective()
False
>>> h.quotient_domain(h.kernel()).is_injective()
True
)r   rF   r   s    r   Úis_injectiveÚModuleHomomorphism.is_injectiveS  s   € ð* �{‰{‹}×$Ñ$Ó&Ð&r   c                 ó<   • U R                  5       U R                  :H  $ )a˜  
Return True if ``self`` is surjective.

That is, check if every element of the codomain has at least one
preimage.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> h = homomorphism(F, F, [[1, 0], [x, 0]])
>>> h.is_surjective()
False
>>> h.restrict_codomain(h.image()).is_surjective()
True
)r!   r   r   s    r   Úis_surjectiveÚ ModuleHomomorphism.is_surjectivej  s   € ð* �z‰z‹|˜tŸ}™}Ñ,Ð,r   c                 óP   • U R                  5       =(       a    U R                  5       $ )aþ  
Return True if ``self`` is an isomorphism.

That is, check if every element of the codomain has precisely one
preimage. Equivalently, ``self`` is both injective and surjective.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> h = homomorphism(F, F, [[1, 0], [x, 0]])
>>> h = h.restrict_codomain(h.image())
>>> h.is_isomorphism()
False
>>> h.quotient_domain(h.kernel()).is_isomorphism()
True
)ru   rx   r   s    r   Úis_isomorphismÚ!ModuleHomomorphism.is_isomorphism�  s!   € ð, × Ñ Ó"×; t×'9Ñ'9Ó';Ð;r   c                 ó>   • U R                  5       R                  5       $ )aÆ  
Return True if ``self`` is a zero morphism.

That is, check if every element of the domain is mapped to zero
under self.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> h = homomorphism(F, F, [[1, 0], [x, 0]])
>>> h.is_zero()
False
>>> h.restrict_domain(F.submodule()).is_zero()
True
>>> h.quotient_codomain(h.image()).is_zero()
True
)r!   rF   r   s    r   rF   ÚModuleHomomorphism.is_zero™  s   € ð. �z‰z‹|×#Ñ#Ó%Ð%r   c                 óH   •  X-
  R                  5       $ ! [         a     gf = f)NF)rF   r   rW   s     r   Ú__eq__ÚModuleHomomorphism.__eq__²  s*   € ð	Ø‘J×'Ñ'Ó)Ð)øÜó 	Ùð	ús   ‚ ”
! !c                 ó   • X:X  + $ rR   © rW   s     r   Ú__ne__ÚModuleHomomorphism.__ne__¸  s   € ØÒ Ð r   )r   r   r   r   r   N)$Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r!   r   r    r.   r2   r6   r:   r?   rC   rG   rJ   rO   rT   rY   r]   r`   rc   rg   Ú__rmul__rk   rn   rr   ru   rx   r{   rF   r€   r„   Ú__static_attributes__rƒ   r   r   r
   r
      s¥   † ñ#òJòò,ò,"ò"ò"ò"ò"ò"ò%)òN+ò@)ò>$+òL"òMò"ò"ò"òKò"ð €Hò"òò
ò
'ò.-ò.<ò0&ò2õ!r   r
   c                   óT   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)ÚMatrixHomomorphismi¼  a�  
Helper class for all homomoprhisms which are expressed via a matrix.

That is, for such homomorphisms ``domain`` is contained in a module
generated by finitely many elements `e_1, \ldots, e_n`, so that the
homomorphism is determined uniquely by its action on the `e_i`. It
can thus be represented as a vector of elements of the codomain module,
or potentially a supermodule of the codomain module
(and hence conventionally as a matrix, if there is a similar interpretation
for elements of the codomain module).

Note that this class does *not* assume that the `e_i` freely generate a
submodule, nor that ``domain`` is even all of this submodule. It exists
only to unify the interface.

Do not instantiate.

Attributes:

- matrix - the list of images determining the homomorphism.
NOTE: the elements of matrix belong to either self.codomain or
      self.codomain.container

Still non-implemented methods:

- kernel
- _apply
c                 óš  ^• [         R                  XU5        [        U5      UR                  :w  a&  [	        SUR                  < S[        U5      < 35      eU R
                  R                  m[        U R
                  [        [        45      (       a   U R
                  R                  R                  m[        U4S jU 5       5      U l        g )NzNeed to provide z elements, got c              3   ó4   >#   • U  H  nT" U5      v •  M     g 7frR   rƒ   )Ú.0ÚxÚ	converters     €r   Ú	<genexpr>Ú.MatrixHomomorphism.__init__.<locals>.<genexpr>ã  s   øé € Ð9²&¨Q™I aŸL˜L²&ùs   ƒ)r
   r   ÚlenÚrankr   r   rS   r   r   r   Ú	containerÚtupleÚmatrix)r   r   r   rš   r“   s       @r   r   ÚMatrixHomomorphism.__init__Ú  s‘   ø€ Ü×#Ñ# D°(Ô;Üˆv‹;˜&Ÿ+™+Ó%ÝØ &§¤¬S°­[ð:ó ;ð ;ð —M‘M×)Ñ)ˆ	Ü�d—m‘m¤iÔ1BÐ%C×DÑDØŸ™×/Ñ/×7Ñ7ˆIÜÔ9±&Ó9Ó9ˆ�r   c                 ó4  • SSK Jn  S n[        U R                  [        [
        45      (       a  S nU" U R                   VVs/ s H3  o2" U5       Vs/ s H  o@R                  R                  U5      PM     snPM5     snn5      R                  $ s  snf s  snnf )z=Helper function which returns a SymPy matrix ``self.matrix``.r   )ÚMatrixc                 ó   • U $ rR   rƒ   ©r’   s    r   Ú<lambda>Ú2MatrixHomomorphism._sympy_matrix.<locals>.<lambda>è  s   € ‘ar   c                 ó   • U R                   $ rR   )ÚdatarŸ   s    r   r    r¡   ê  s   € ˜!Ÿ&š&r   )
Úsympy.matricesr�   r   r   r   r   rš   r   Úto_sympyÚT)r   r�   r\   r’   Úys        r   Ú_sympy_matrixÚ MatrixHomomorphism._sympy_matrixå  sp   € å)ÙˆÜ�d—m‘m¤nÔ6GÐ%H×IÑIÙ ˆAÙÀdÇkÂkÔRÂkÀ°q¸´tÓ<²t°!Ÿ	™	×*Ñ*¨1Ö-±tÔ<ÁkÒRÓS×UÑUÐUùÒ<ùÓRs   ÁB
Á$BÁ6B
ÂB
c                 óŒ  • [        U R                  5       5      R                  S5      nSU R                  < SU R                  < 3nS[        U5      -  n[        U5      n[        US-  5       H  nX==   U-  ss'   M     XS-  ==   U-  ss'   [        US-  S-   U5       H  nX==   U-  ss'   M     SR                  U5      $ )NÚ
z : z -> Ú é   rj   )Úreprr¨   Úsplitr   r   r–   ÚrangeÚjoin)r   ÚlinesÚtÚsÚnÚis         r   Ú__repr__ÚMatrixHomomorphism.__repr__í  s¨   € Ü�T×'Ñ'Ó)Ó*×0Ñ0°Ó6‰Ø!Ÿ[œ[¨$¯-«-Ð8ˆØ”�A“‰JˆÜ�‹JˆÜ�q˜A‘v–ˆAØ‹H˜‰M�Hñ à�1‰f‹˜Ñ‹Ü�q˜!‘t˜a‘x Ö#ˆAØ‹H˜‰M�Hñ $à�y‰y˜ÓÐr   c                 óB   • [        XR                  U R                  5      $ r+   )ÚSubModuleHomomorphismr   rš   r,   s     r   r.   Ú#MatrixHomomorphism._restrict_domainù  s   € ä$ R¯©¸¿¹ÓDÐDr   c                 óN   • U R                  U R                  XR                  5      $ r1   )Ú	__class__r   rš   r,   s     r   r2   Ú%MatrixHomomorphism._restrict_codomainý  s   € à�~‰~˜dŸk™k¨2¯{©{Ó;Ð;r   c                 ój   • U R                  U R                  U-  U R                  U R                  5      $ r5   ©r½   r   r   rš   r,   s     r   r6   Ú#MatrixHomomorphism._quotient_domain  s%   € à�~‰~˜dŸk™k¨"™n¨d¯m©m¸T¿[¹[ÓIÐIr   c           
      ó@  • U R                   U-  nUR                  n[        U R                   [        5      (       a  UR                  R                  nU R                  U R                  U R                   U-  U R                   Vs/ s H
  oC" U5      PM     sn5      $ s  snf r9   )r   rS   r   r   r˜   r½   r   rš   )r   r-   ÚQr“   r’   s        r   r:   Ú%MatrixHomomorphism._quotient_codomain  sx   € à�M‰M˜"ÑˆØ—I‘Iˆ	Ü�d—m‘m¤Y×/Ñ/ØŸ™×+Ñ+ˆIØ�~‰~˜dŸk™k¨4¯=©=¸Ñ+;Ø#'§;¢;Ó/¢;˜aˆY�qŽ\¡;Ñ/ó1ð 	1ùÚ/s   ÂBc           
      óÆ   • U R                  U R                  U R                  [        U R                  UR                  5       VVs/ s H	  u  p#X#-   PM     snn5      $ s  snnf rR   )r½   r   r   Úziprš   )r   rX   r’   r§   s       r   r`   ÚMatrixHomomorphism._add  sK   € Ø�~‰~˜dŸk™k¨4¯=©=Ü14°T·[±[À#Ç*Á*Ô1MÔNÒ1M©¨˜qœuÑ1MÒNóPð 	PùÛNs   ÁAc           	      ó”   • U R                  U R                  U R                  U R                   Vs/ s H  o!U-  PM	     sn5      $ s  snf rR   rÀ   )r   r\   r’   s      r   r]   ÚMatrixHomomorphism._mul_scalar  s5   € Ø�~‰~˜dŸk™k¨4¯=©=ÈÏÊÓ:TÊÀ1¸Q¼3ÉÑ:TÓUÐUùÒ:Ts   °Ac           
      óš   • U R                  U R                  UR                  U R                   Vs/ s H
  o!" U5      PM     sn5      $ s  snf rR   rÀ   )r   rX   r’   s      r   rY   ÚMatrixHomomorphism._compose  s7   € Ø�~‰~˜dŸk™k¨3¯<©<È$Ï+Ê+Ó9VÊ+ÀQ¸#¸a¾&É+Ñ9VÓWÐWùÒ9Vs   °A)rš   N)r†   r‡   rˆ   r‰   rŠ   r   r¨   r·   r.   r2   r6   r:   r`   r]   rY   rŒ   rƒ   r   r   rŽ   rŽ   ¼  s?   † ñò:	:òVò
 òEò<òJò1òPòVõXr   rŽ   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚFreeModuleHomomorphismi  a¼  
Concrete class for homomorphisms with domain a free module or a quotient
thereof.

Do not instantiate; the constructor does not check that your data is well
defined. Use the ``homomorphism`` function instead:

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> F = QQ.old_poly_ring(x).free_module(2)
>>> homomorphism(F, F, [[1, 0], [0, 1]])
Matrix([
[1, 0], : QQ[x]**2 -> QQ[x]**2
[0, 1]])
c                 ó¢   • [        U R                  [        5      (       a  UR                  n[	        S [        XR                  5       5       5      $ )Nc              3   ó.   #   • U  H  u  pX-  v •  M     g 7frR   rƒ   ©r‘   r’   Úes      r   r”   Ú0FreeModuleHomomorphism._apply.<locals>.<genexpr>/  ó   é € Ð<Ò%;™T˜Q�1–5Ò%;ùó   ‚)r   r   r   r£   ÚsumrÆ   rš   rM   s     r   rO   ÚFreeModuleHomomorphism._apply,  s6   € Ü�d—k‘k¤>×2Ñ2Ø—9‘9ˆDÜÑ<¤S¨¯{©{Ô%;Ó<Ó<Ð<r   c                 óH   • U R                   R                  " U R                  6 $ rR   )r   Ú	submodulerš   r   s    r   r    ÚFreeModuleHomomorphism._image1  s   € Ø�}‰}×&Ò&¨¯©Ð4Ð4r   c                 ó„   • U R                  5       R                  5       nU R                  R                  " UR                  6 $ rR   )r!   Úsyzygy_moduler   rØ   Úgens)r   Úsyzs     r   r   ÚFreeModuleHomomorphism._kernel4  s1   € ð �j‰j‹l×(Ñ(Ó*ˆØ�{‰{×$Ò$ c§h¡hÐ/Ð/r   rƒ   N©	r†   r‡   rˆ   r‰   rŠ   rO   r    r   rŒ   rƒ   r   r   rÍ   rÍ     s   † ñò$=ò
5õ0r   rÍ   c                   ó*   • \ rS rSrSrS rS rS rSrg)rº   i>  aÜ  
Concrete class for homomorphism with domain a submodule of a free module
or a quotient thereof.

Do not instantiate; the constructor does not check that your data is well
defined. Use the ``homomorphism`` function instead:

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> M = QQ.old_poly_ring(x).free_module(2)*x
>>> homomorphism(M, M, [[1, 0], [0, 1]])
Matrix([
[1, 0], : <[x, 0], [0, x]> -> <[x, 0], [0, x]>
[0, 1]])
c                 ó¢   • [        U R                  [        5      (       a  UR                  n[	        S [        XR                  5       5       5      $ )Nc              3   ó.   #   • U  H  u  pX-  v •  M     g 7frR   rƒ   rÐ   s      r   r”   Ú/SubModuleHomomorphism._apply.<locals>.<genexpr>T  rÓ   rÔ   )r   r   r   r£   rÕ   rÆ   rš   rM   s     r   rO   ÚSubModuleHomomorphism._applyQ  s7   € Ü�d—k‘kÔ#4×5Ñ5Ø—9‘9ˆDÜÑ<¤S¨¯{©{Ô%;Ó<Ó<Ð<r   c                 ó’   • U R                   R                  " U R                  R                   Vs/ s H
  o" U5      PM     sn6 $ s  snf rR   )r   rØ   r   rÜ   )r   r’   s     r   r    ÚSubModuleHomomorphism._imageV  s9   € Ø�}‰}×&Ò&¸$¿+¹+×:JÒ:JÓ(KÒ:J°Q¨¨a®Ñ:JÑ(KÐLÐLùÒ(Ks   ¯Ac                 ó
  • U R                  5       R                  5       nU R                  R                  " UR                   Vs/ s H2  n[        S [        X R                  R                  5       5       5      PM4     sn6 $ s  snf )Nc              3   ó.   #   • U  H  u  pX-  v •  M     g 7frR   rƒ   )r‘   ÚxiÚgis      r   r”   Ú0SubModuleHomomorphism._kernel.<locals>.<genexpr>\  s   é € Ð?Ò&>™F˜B�"–%Ò&>ùrÔ   )r!   rÛ   r   rØ   rÜ   rÕ   rÆ   )r   rÝ   r´   s      r   r   ÚSubModuleHomomorphism._kernelY  sk   € Ø�j‰j‹l×(Ñ(Ó*ˆØ�{‰{×$Ò$à—x’xó!Ú�!ô Ñ?¤c¨!¯[©[×-=Ñ-=Ô&>Ó?Ö?Ùñ!ð"ð 	"ùò!s   Á9B rƒ   Nrß   rƒ   r   r   rº   rº   >  s   † ñò$=ò
Mõ"r   rº   c           
      óú   • S nU" U 5      u  pEpgU" U5      u  p‰p«[        XHU Vs/ s H
  oË" U5      PM     sn5      R                  U5      R                  U	5      R                  U
5      R	                  U5      $ s  snf )a‚  
Create a homomorphism object.

This function tries to build a homomorphism from ``domain`` to ``codomain``
via the matrix ``matrix``.

Examples
========

>>> from sympy import QQ
>>> from sympy.abc import x
>>> from sympy.polys.agca import homomorphism

>>> R = QQ.old_poly_ring(x)
>>> T = R.free_module(2)

If ``domain`` is a free module generated by `e_1, \ldots, e_n`, then
``matrix`` should be an n-element iterable `(b_1, \ldots, b_n)` where
the `b_i` are elements of ``codomain``. The constructed homomorphism is the
unique homomorphism sending `e_i` to `b_i`.

>>> F = R.free_module(2)
>>> h = homomorphism(F, T, [[1, x], [x**2, 0]])
>>> h
Matrix([
[1, x**2], : QQ[x]**2 -> QQ[x]**2
[x,    0]])
>>> h([1, 0])
[1, x]
>>> h([0, 1])
[x**2, 0]
>>> h([1, 1])
[x**2 + 1, x]

If ``domain`` is a submodule of a free module, them ``matrix`` determines
a homomoprhism from the containing free module to ``codomain``, and the
homomorphism returned is obtained by restriction to ``domain``.

>>> S = F.submodule([1, 0], [0, x])
>>> homomorphism(S, T, [[1, x], [x**2, 0]])
Matrix([
[1, x**2], : <[1, 0], [0, x]> -> QQ[x]**2
[x,    0]])

If ``domain`` is a (sub)quotient `N/K`, then ``matrix`` determines a
homomorphism from `N` to ``codomain``. If the kernel contains `K`, this
homomorphism descends to ``domain`` and is returned; otherwise an exception
is raised.

>>> homomorphism(S/[(1, 0)], T, [0, [x**2, 0]])
Matrix([
[0, x**2], : <[1, 0] + <[1, 0]>, [0, x] + <[1, 0]>, [1, 0] + <[1, 0]>> -> QQ[x]**2
[0,    0]])
>>> homomorphism(S/[(0, x)], T, [0, [x**2, 0]])
Traceback (most recent call last):
...
ValueError: kernel <[1, 0], [0, 0]> must contain sm, got <[0,x]>

c                 óª  ^ • [        T [        5      (       a  T T T R                  5       U 4S j4$ [        T [        5      (       a(  T R                  T R                  T R
                  U 4S j4$ [        T [        5      (       a2  T R                  R                  T R                  T R
                  U 4S j4$ T R                  T T R                  5       U 4S j4$ )z¾
Return a tuple ``(F, S, Q, c)`` where ``F`` is a free module, ``S`` is a
submodule of ``F``, and ``Q`` a submodule of ``S``, such that
``module = S/Q``, and ``c`` is a conversion function.
c                 ó&   >• TR                  U 5      $ rR   )rS   ©r’   Úmodules    €r   r    Ú0homomorphism.<locals>.freepres.<locals>.<lambda>£  s   ø€ ÀÇÁÐPQÔARr   c                 ó:   >• TR                  U 5      R                  $ rR   )rS   r£   rð   s    €r   r    rò   ¦  s   ø€ ˜fŸn™n¨QÓ/×4Ò4r   c                 óN   >• TR                   R                  U 5      R                  $ rR   )r˜   rS   r£   rð   s    €r   r    rò   ©  s   ø€ ˜f×.Ñ.×6Ñ6°qÓ9×>Ò>r   c                 ó:   >• TR                   R                  U 5      $ rR   )r˜   rS   rð   s    €r   r    rò   ¬  s   ø€ ˜&×*Ñ*×2Ñ2°1Ô5r   )r   r   rØ   r   ÚbaseÚkilled_moduler   r˜   )rñ   s   `r   ÚfreepresÚhomomorphism.<locals>.freepresœ  s·   ø€ ô �fœj×)Ñ)Ø˜6 6×#3Ñ#3Ó#5Ô7RÐRÐRÜ�fœn×-Ñ-Ø—K‘K §¡¨f×.BÑ.BÜ4ð6ð 6ä�fÔ/×0Ñ0Ø—K‘K×)Ñ)¨6¯;©;¸×8LÑ8LÜ>ð@ð @ð × Ñ  &¨&×*:Ñ*:Ó*<Ü5ð7ð 	7r   )rÍ   r?   rC   rJ   rG   )r   r   rš   rø   ÚSFÚSSÚSQÚ_ÚTFÚTSÚTQr\   r’   s                r   Úhomomorphismr  `  sx   € òx7ñ$ ˜VÓ$�M€BˆBÙ˜XÓ&�M€BˆBä! "¹Ó*@º°A¨1¨Q®4¹Ñ*@ó ß‰?˜2Ó×0Ñ0°ó  ßÑ˜RÓ §¡°Ó!4ð5ùÒ*@s   ¤A8N)rŠ   Úsympy.polys.agca.modulesr   r   r   r   r   Úsympy.polys.polyerrorsr   r
   rŽ   rÍ   rº   r  rƒ   r   r   Ú<module>r     sX   ðñ÷"õ "å 1÷g!ñ g!ôTZXÐ+ô ZXôz"0Ð/ô "0ôJ"Ð.ô "óDS5r   