Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
181 views
unlisted
ubuntu2004
o

��cn,�@sHddlmZddlmZddlmZddlZddlZGdd�de�Z	dS)�)�Counter)�
SageObject)�
cached_methodNc@s�eZdZdZd1dd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zedd ��Zd!d"�Z	#	#d2d$d%�Zd&d'�Zed(d)��Zed*d+��Zd,d-�Zd.d/�Zd0S)3�ELGTautClassaT
    A Tautological class of a stratum X, i.e. a formal sum of of psi classes on
    EmbeddedLevelGraphs.

    This is encoded by a list of summands.

    Each summand corresponds to an AdditiveGenerator with coefficient.

    Thus an ELGTautClass is a list with entries tuples (coefficient, AdditiveGenerator).

    These can be added, multiplied and reduced (simplified).

    INPUT :

      * X : GeneralisedStratum that we are on
      * psi_list : list of tuples (coefficient, AdditiveGenerator) as
            described above.
      * reduce=True : call self.reduce() on initialisation
    TcCs ||_||_|r|��dSdS�N)�	_psi_list�_X�reduce)�self�X�psi_listr	�r
�E/home/user/Introduction lectures/admcycles/diffstrata/elgtautclass.py�__init__ s
�zELGTautClass.__init__cs|��fdd�|D�dd�S)Ncsg|]\}}|��|�f�qSr
)�additive_generator_from_hash)�.0�c�h�rr
r�
<listcomp>)s�z/ELGTautClass.from_hash_list.<locals>.<listcomp>F�r	r
)�clsrZ	hash_listr
rr�from_hash_list&s
��zELGTautClass.from_hash_listcCs|jSr)r�r
r
r
rr,szELGTautClass.psi_listcCsd|j|jfS)NzELGTautClass(X=%r,psi_list=%r)�rrrr
r
r�__repr__0s
�zELGTautClass.__repr__cCs.d|j}|jD]\}}|d||f7}q|S)NzTautological class on %s
z%s * %s + 
r)r
�str�coeff�psir
r
r�__str__4s
zELGTautClass.__str__cCs@t|tjjj�r||��kSz|j|jkWStyYdSw)NF)�
isinstance�	admcycles�
diffstrata�additivegenerator�AdditiveGenerator�as_tautr�AttributeError�r
�otherr
r
r�__eq__:s��zELGTautClass.__eq__cCsP|dkr|Sz|j|jkstWS|j|j}t|j|�WSty'tYSw)Nr)r�NotImplementedrrr&�r
r(�new_psisr
r
r�__add__Ds�zELGTautClass.__add__cC�
|�|�Sr�r-r'r
r
r�__iadd__P�
zELGTautClass.__iadd__cCr.rr/r'r
r
r�__radd__Sr1zELGTautClass.__radd__cCsd|S�N�����r
rr
r
r�__neg__VszELGTautClass.__neg__cCs|d|Sr3r
r'r
r
r�__sub__YszELGTautClass.__sub__cs�d�krdS|jj�kr|St�tjjj�r|���Sz�jWnt	y<�fdd�|jD�}t
|j|dd�YSw|j�jksEtS|j�|��S)Nrcsg|]
\}}|�|f�qSr
r
)rrr�r(r
rrk�z(ELGTautClass.__mul__.<locals>.<listcomp>Fr)
r�ONEr r!r"r#r$r%rr&rr*�intersectionr+r
r7r�__mul__\s$�
�zELGTautClass.__mul__cCr.r)r;r'r
r
r�__rmul__rr1zELGTautClass.__rmul__cCs0|dkr|jjS|}td|�D]}||}q|S)Nr�)rr9�range)r
�exponent�prod�_r
r
r�__pow__us
zELGTautClass.__pow__cs2|jr|jddj�t�fdd�|jD��SdS)a
        Determine if all summands of self have the same degree.

        Note that the empty empty tautological class (ZERO) gives True.

        Returns:
            bool: True if all AdditiveGenerators in self.psi_list are of same degree,
                False otherwise.
        rr=c3s�|]
\}}|j�kVqdSr)�degree)r�_c�AG�Z	first_degr
r�	<genexpr>�s�z2ELGTautClass.is_equidimensional.<locals>.<genexpr>T)rrC�allrr
rFr�is_equidimensional~szELGTautClass.is_equidimensionalcCs>t�}|jD]\}}|||7<qdd�|��D�|_dS)z�
        Reduce self.psi_list by combining summands with the same AdditiveGenerator
        and removing those with coefficient 0 or that die for dimension reasons.
        cSs(g|]\}}|dkr|��r||f�qS)r)�	dim_check)rrErr
r
rr�s
��z'ELGTautClass.reduce.<locals>.<listcomp>N)rr�items)r
Z	hash_dictrrEr
r
rr	�szELGTautClass.reduceFc
Cs�|rd}g}|jD]\}}|j|||d�}|�||�q	|sVtd�td�t|�D]\}}	td|	�t|j|d�td|j|d�q+td	t|��td�t|�S)
a�
        Evaluation of self, i.e. cap with fundamental class of X.

        This is the sum of the evaluation of the AdditiveGenerators in psi_list
        (weighted with their coefficients).

        Each AdditiveGenerator is (essentially) the product of its levels,
        each level is (essentially) evaluated by admcycles.

        Args:
            quiet (bool, optional): No output. Defaults to True.
            warnings_only (bool, optional): Only warnings output. Defaults to False.
            admcycles_output (bool, optional): admcycles debugging output. Defaults to False.

        Returns:
            QQ: integral of self on X

        EXAMPLES::

            sage: from admcycles.diffstrata import *
            sage: X=GeneralisedStratum([Signature((0,0))])
            sage: assert (X.xi^2).evaluate() == 0

            sage: X=GeneralisedStratum([Signature((1,1,1,1,-6))])
            sage: assert set([(X.cnb(((i,),0),((i,),0))).evaluate() for i in range(len(X.bics))]) == {-2, -1}
        T)�quiet�
warnings_only�admcycles_outputz4----------------------------------------------------zIn summary: We sumz&Contribution %r from AdditiveGeneratorr=z(With coefficient %r)rzTo obtain a total of %r)r�evaluate�append�print�	enumerate�sum)
r
rLrMrNZDS_listrrE�value�i�summandr
r
rrO�s(�zELGTautClass.evaluatecCst|j|j|gdd�S)z�
        Return the i-th component of self.

        Args:
            i (int): index of self._psi_list

        Returns:
            ELGTautClass: coefficient * AdditiveGenerator at position i of self.
        Fr)rrr)r
rUr
r
r�extract�s
zELGTautClass.extractcCs<g}|jD]\}}|j|kr|�||f�qt|j|dd�S)z�
        The degree d part of self.

        Args:
            d (int): degree

        Returns:
            ELGTautClass: degree d part of self
        Fr)rrCrPrr)r
�dr,rrEr
r
rrC�s
�zELGTautClass.degreecsRdd�t�j��d�D�}�jD]\}}||j�||f�q�fdd�|D�S)z�
        A list of length X.dim with the degree d part as item d

        Returns:
            list: list of ELGTautClasses with entry i of degree i.
        cSsg|]}g�qSr
r
)rrAr
r
rr�sz/ELGTautClass.list_by_degree.<locals>.<listcomp>r=csg|]
}t�j|dd��qS)Fr)rr)r�piecerr
rr�s�)r>r�dimrrCrP)r
Zdeg_psi_listrrEr
rr�list_by_degree�s
�zELGTautClass.list_by_degreecCs,|jsdSt|j�dko|jddjdkS)a*
        Check if self is ZERO or a psi-product on the stratum.

        Returns:
            boolean: True if self has at most one summand and that is of the form
                AdditiveGenerator(((), 0), psis).

        EXAMPLES::

            sage: from admcycles.diffstrata import *
            sage: X=Stratum((2,))
            sage: X.ZERO.is_pure_psi()
            True
            sage: X.ONE.is_pure_psi()
            True
            sage: X.psi(1).is_pure_psi()
            True
            sage: X.xi.is_pure_psi()
            False
        Tr=r)r
r)r�len�enh_profilerr
r
r�is_pure_psi�s���zELGTautClass.is_pure_psics�|jj��jj}tjj|gd�}|jD]d\}}|��}i}t�jj	�D]9\}}�j
�jj|d}	|jj
|	}
|jj}|�|
�}|�|�}
|���|
�D]\}}}|dkrWqM|||<qMq#�fdd�|jj
��D�}|�|||�}|||7}q|S)a�
        Transforms self into an admcycles prodtautclass on the stable graph of the smooth
        graph of self._X.

        Note that this is essentially the pushforward to M_g,n, i.e. we resolve residues
        and multiply with the correct Strataclasses along the way.

        Returns:
            prodtautclass: admcycles prodtautclass corresponding to self pushed forward
                to the stable graph with one vertex.

        EXAMPLES::

            sage: from admcycles.diffstrata import *
            sage: X=Stratum((2,))
            sage: X.ONE.to_prodtautclass()
            Outer graph : [2] [[1]] []
            Vertex 0 :
            Graph :      [2] [[1]] []
            Polynomial : -7/24*(kappa_1)_0 + 79/24*psi_1
            <BLANKLINE>
            <BLANKLINE>
            Vertex 0 :
            Graph :      [1] [[1, 2, 3]] [(2, 3)]
            Polynomial : -1/48
            <BLANKLINE>
            <BLANKLINE>
            Vertex 0 :
            Graph :      [1, 1] [[2], [1, 3]] [(2, 3)]
            Polynomial : -19/24
            sage: (X.xi^X.dim()).evaluate() == (X.xi^X.dim()).to_prodtautclass().pushforward().evaluate()
            True
        )�termsr�LGcsi|]
\}}�j||�qSr
)�dmp_inv)rZldeg�mp��Gr
r�
<dictcomp>Lr8z1ELGTautClass.to_prodtautclass.<locals>.<dictcomp>)r�	smooth_LGr`�stgraphr!�
prodtautclassr�to_prodtautclassrR�genera�dmp�legs�_Gra�vertex�	UG_vertexZUG_without_infinity�%connected_component_containing_vertexrK�partial_pushforward)r
rg�totalrrE�ptc�
vertex_map�vrAZ
mp_on_stratumZl_AGr`Zv_AGZUG_v�w�g�kind�leg_map�pfr
rcrris."

�
�zELGTautClass.to_prodtautclassN)T)TFF)�__name__�
__module__�__qualname__�__doc__r�classmethodr�propertyrrrr)r-r0r2r5r6r;r<rBrrIr	rOrWrCr[r^rir
r
r
rrs>



	

�0


r)
�collectionsr�sage.structure.sage_objectr�sage.misc.cachefuncr�&admcycles.diffstrata.additivegeneratorr!�admcycles.admcyclesrr
r
r
r�<module>s