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

��c�r�@sdZddlmZddlmZddlZddlmZddlm	Z	ddl
mZddlm
Z
dd	lmZdd
lmZddlmZddlmZd
dlmZddlmZddlZddlZddlZd
dlmZdd�Z dd�Z!dd�Z"d"dd�Z#d#dd�Z$edd��Z%d d!�Z&dS)$z� Recursive computation of strata of k-differentials

This is following the papers [FaPa18]_ by Farkas-Pandharipande and [Sch18]_ by Schmitt.
�)�Iterable)�deepcopyN)�subsets)�IntegerVectors��
Partitions)�prod)�ZZ)�cached_function)�Word��ceil�)�StableGraph)�DR_cycle)�TautologicalRingcCsl|sgSg}dg}|d}tdt|��D]4}|||krD||g7}q(||g7}|g}||}q(||g7}|S)z�
    INPUT:

    - l -- a list

    EXAMPLES::

        sage: from admcycles.stratarecursion import classes
        sage: classes([])
        []
        sage: classes([4,4,3,3,3,1,1])
        [[0, 1], [2, 3, 4], [5, 6]]
    rr)�range�len)�l�indices�currentZcurrentitem�i�r�=/home/user/Introduction lectures/admcycles/stratarecursion.py�classes-s


rcCsx|dkrgS|dkr"|rgSggS|dkr2|ggSg}t|�D]4}t|t|�|d�D]}|�t|�g|�qXq>|S)a�
    Return a list of partitions of the set S into the disjoint union of s sets.

    A partition is a list of sets.

    EXAMPLES::

        sage: from admcycles.stratarecursion import SetPart
        sage: S = set(['b','o','f'])
        sage: SetPart(S,2)
        [[set(), {'b', 'f', 'o'}],
        ...
        [{'b', 'f', 'o'}, set()]]
        sage: SetPart(S,1)
        [[{'b', 'f', 'o'}]]
        sage: SetPart(S,-1)
        []
        sage: SetPart(S,0)
        []
    rr)r�SetPart�set�append)�S�s�resu�T�rrrrrKsrcsZt���g}g}g}tt���D]6���dks@���dkrL|���q |���q t�fdd�|D��}t|d�D�]�}t||�D�]��	t�	���	fdd��D�}tj|�D�]�}	||gg�d}
tt���D]Z�tt|	���D]D�����	�fdd�t|	���D�7�|
|	���d7}
q�q�t	|�D�]
�|dk�rh|
t|�t��dk�rh�q:t�fdd��D��}��
||��s��q:�fd	d�|D�}||�d|
d|d}
t���t|
t��d�D�]b}g}tt��d�D]~�g}t|�t��d�t��d�d
�D]<�����fdd�tt��d��D�}|tj|�7}�q,|�|��q�tj|�D�]�}t��}|dd�7<d}|D]&��D]��||d<|d7}�q��q�t|��
t
t|�t�
�d�D�]F���
fd
d�tt�
�d�D�}|�s(|�r(�q�tj|�D�]}t|�}d}d}|D]���D]x�t��||d<d||dd��tdd�||dD��t�fdd�||dD��k�r�d}|d7}�qT�qL|�r2|ddttdd�|ddD���ff}|tt�fdd�|dd�D���7}|�|��q2�q�q��qސq:q�q�qztt|��S)Nrcsg|]}�|�qSrr��.0r��murr�
<listcomp>}�ztwistenum.<locals>.<listcomp>rcs"g|]}tt|��|d��qS�r)rr�r$�c)�
totgenlistrrr'�r(cs,g|]$}���d�g�dgg�qS)rrr)r$�_)�cl�jr,�zrrr'�s��csg|]}�|�qSrrr#r%rrr'�r(csg|]}|�vr|�qSrr�r$�b)�	markings0rrr'�r(��lengthcsLg|]D}t�|���d|dd���d|dd��qS)rr1r5r�r$�v)�coarsetwistdist�grar�vertclrrr'�s�8��cs&g|]}t�|t�|d���qS�r)rrr*)�pa�twiclarrr'�s�Tcss|]}|dVqdS�rNr�r$rrrr�	<genexpr>�r(ztwistenum.<locals>.<genexpr>c3s|]}�|VqdS�NrrAr%rrrB�r(Fcss|]}|dVqdSr@r�r$�mrrrrB�r(c3sH|]@\}}}}|ttdd�|D���tt�fdd�|D���fVqdS)css|]}|dVqdSr@rrDrrrrB�r(z&twistenum.<locals>.<genexpr>.<genexpr>c3s|]}�|VqdSrCr)r$�t��krrrB�r(N)�tuple�sorted)r$�gvZmarkiZenuZetwistrGrrrB�s
��)r	rrr�sumrr�	itertools�productr�dividesrrrr�listrIrJ)�grHr&�lis�A�BZAtot�g0�par�pZnumedZBtotZBrestZItotalZcoarsesttwistdist�twistZvertcltwistlistZ	inditwist�indeZgrap�countZmpar�part�graphZadmZsgraphr)
r.r9r:rr/rHr4r&r>r,r?r;r0r�	twistenumqs�
�$ 0��
�V(�
�$r]Fr�pullc	&	sVt���t���}	t���t���d�dkr:td��t�fdd��D��}
|r�d}tdd��D��rrtd���dkr��ddkr�td	��|r�|
r�|d
ks�|dkr�t�d}n|d
kr�|
r�|r�d}�dkr�|s�|s�|	��Std
d��D���r|�s|�s|�r|	��S|	��S|dk�s<|dk�s<tdd�|D���r�g}|D]\}t	|t
��r�tdd�|D���sptd��|�dd�t|�D��n|�d|dfg��qDt
jjjt
jj�t���g|d�}
|
j|}|�r�t
jj�|�}|����S|����St|�dk�r:�dk�std��|�r(td��t|�}dd�t��D�}t|�dk�r`t���|d�St�fdd�|D���r�td��t�fdd�|D���r�|	��St�fdd�|D��}�|d��g�fdd�|D��g}g�d}gg}�fdd�tt|��D�}td�d�D]�}||v�rL|d�|�|��|d�|d7}n�|d����|dddk�r�|��dg����|ddg�n@|��d|g����|dddg�|�d�|d7}�d7��qt�||�}t��}t|�|dd�}|�|�}|� d��fdd�tt|��D��S�dk�rn|
�sn|�snt�dt�fd d��D���St!���"��#�}d!d"�t|�D�}tt���}zLt$�%��|||�}|
�s�|�r�|	�&|��}n|	�&|�d�}|�'|�|WSt(�y�Yn0|
�s
|�r�t)��|�} t�fd#d�t| �D��}!t|!�dk�sRJ���t|!�f��| �*|!d�t+�t�fd$d�|D��|d%�}"|"t,��|| ||d&�8}"|"�-��}t$j.|g��|||f�R�|	�&|��}"|"�'|�|"S�dk�s�J���f��t/|�d'g}#|#�dd7<t|#�}#t)��|#�} t�fd(d�t| �D��}!t|!�dk�sbJ���t|!�f��| �*|!d�t��fd)d�t| �D��}$t|$�dk�s�J���f��| �*|$d�t+�t�fd*d�|#D���}%|%t,��|#| d+�8}%|%�0�dg�}"|"d|#�d9}"|"�-�d�}t$j.|g��|||f�R�|	�&|�d�}"|"�'|�|"Sd,S)-a�
    Returns the fundamental class of the closure of the stratum of k-differentials in genus g in Mbar_{g,n}
    with vanishing and pole orders mu.

    The class is computed using a formula from papers by Farkas-Pandharipande and Schmitt,
    proven by [HoSc]_ and [BHPSS]_.
    The formula for differentials with residue conditions is based on unpublished work
    relying on [BaChGeGrMo]_.

    If the mu is of spin type, we can compute the spin stratum class H^+ - H^-. In [CSS21]_, Costantini,
    Sauvaget and Schmitt made a similar conjecture for the Pixton formula.

    INPUT:

    - ``g``  -- integer ; genus of the curves

    - ``k`` -- integer ; power of the canonical line bundle in definition of stratum

    - ``mu`` -- tuple ; tuple of integers of length n giving zero and pole multiplicities
      of k-differential, required to sum up to k*(2g-2)

    - ``virt``   -- bool (default: `False`); if True, k=1 and all entries of mu nonnegative, this
      computes the virtual codimension g class supported on the codimension g-1 stratum of
      holomorphic 1-differentials.

    - ``res_cond``   -- tuple (default: `()`); tuple of residue conditions. Each entry of
      res_cond can be of one of the following two types:

        - an integer i from 1, ..., n indicating a marking pi with mu[i]<0, such that the
          differential eta is required to have a pole with vanishing residue at the marking.

        - a tuple (c1, ..., cn) of rational numbers indicating that a condition
          c1 * Res_{p1}(eta) + ... + cn * Res_{pn}(eta) = 0
          is imposed. Currently only implemented for ci in {0,1}.

      The function then computes the class of the closure of the locus of smooth curves
      having such a differential eta. Currently only implemented for k=1.

    - ``xi_power``   -- integer (default: `0`); if positive, returns the pushforward of
      the corresponding power of the first Chern class xi = c_1(O(-1)) of the tautological
      bundle on the moduli space of multi-scale differentials from [BCGGM3].
      Currently only implemented for k=1 and with method = 'diffstrata'.

    - ``method``   -- string (default: `'pull'`); when computing a stratum of 1-differentials
      with residue conditions, there are two choices here: 'pull' will compute it via boundary
      pullbacks of higher genus strata, 'diffstrata' will use the package `diffstrata`, which
      iteratively replaces residue conditions with equivalent divisorial conditions. The two
      results should be equal.

    - ``spin``   -- bool (default: `False`); if true, we will compute the spin stratum class

    - ``spin_conj``   -- bool (default: `False`); if we assume the conjecture in [CSS21]_ to be true,
      we will compute the spin stratum class by first compute the holomorphic strata of the same genus,
      then use the conjecture to recursively compute the input stratum class

    WARNING::

        Imposing residue conditions at poles of high order leads to very long computations,
        since the method works by computing strata of differentials on high-genus moduli
        spaces.

    TESTS::

        sage: from admcycles import Hyperell, Biell
        sage: from admcycles.stratarecursion import Strataclass
        sage: L=Strataclass(2,1,(3,-1)); L.is_zero()
        True
        sage: L=Strataclass(3,1,(5,-1)); L.is_zero() # doctest: +SKIP
        True
        sage: L=Strataclass(2,1,(2,)); (L-Hyperell(2,1)).is_zero()
        True

    In g=2, the locus Hbar_2(2,2) decomposes into the codimension 1 set of Hbar_2(1,1) and the
    codimension 2 set of curves (C,p,q) with p,q Weierstrass points. The latter is equal to the cycle
    Hyperell(2,2). We can obtain it by subtracting the virtual cycle for the partition (1,1) from the
    virtual cycle for the partition (2,2)::

        sage: H1 = Strataclass(2, 2, (2, 2), virt = True)
        sage: H2 = Strataclass(2, 1, (1, 1), virt = True)
        sage: T = H1 - H2 - Hyperell(2, 2)
        sage: T.is_zero()
        True

    In g=1, the locus Hbar_1(2,-2) is the locus of curves (E,p,q) with p-q being 2-torsion in E.
    Equivalently, this is the locus of bielliptic curves with a pair of bielliptic conjugate points::

        sage: (Strataclass(1,1,(2,-2)) - Biell(1,0,1)).is_zero()
        True

    Some tests of computations involving residue conditions::

        sage: from admcycles import Strataclass
        sage: OmegaR = Strataclass(1,1,(6,-4,-2),res_cond=(3,))
        sage: OmegaRalt = Strataclass(1,1,(6,-4,-2),res_cond=(2,)) # long time
        sage: (OmegaR - OmegaRalt).is_zero() # long time
        True
        sage: (OmegaR.forgetful_pushforward([2,3])).fund_evaluate()
        42
        sage: a=4; (a+2)**2 + a**2 - 10 # formula from [Castorena-Gendron, Cor. 5.5]
        42
        sage: OmegaR2 = Strataclass(1,1,(4,-2,-2),res_cond=(3,))
        sage: (OmegaR2.forgetful_pushforward([2,3])).fund_evaluate()
        10
        sage: OmegaR3 = Strataclass(1,1,(5,-3,-2),res_cond=(2,)) #  not tested
        sage: (OmegaR3.forgetful_pushforward([2,3])).fund_evaluate() #  not tested
        24
        sage: a=3; (a+2)**2 + a**2 - 10 # formula from [Castorena-Gendron, Cor. 5.5] #  not tested
        24
        sage: OmegaR5 = Strataclass(2,1,(5,-1,-2),res_cond=(3,)) #  not tested
        sage: OmegaR5.is_zero() # vanishes by residue theorem # not tested
        True

    We can also check that the two ways of computing residue conditions (via pullbacks and
    via the package diffstrata) coincide::

        sage: a = Strataclass(1,1,(4,-2,-2), res_cond=(2,))
        sage: b = Strataclass(1,1,(4,-2,-2), res_cond=(2,), method='diffstrata')
        sage: (a-b).is_zero()
        True

    The following computes the locus of genus 1 curves admitting a differential with multiplicity
    vector (8,-2,-2,-2,-2) at the markings such that the sum of residues at p2 and p3 equals zero::

        sage: c = Strataclass(1,1,(8,-2,-2,-2,-2), res_cond=((0,1,1,0,0),))

    Using the parameter xi_power, we can observe an interesting relationship between strata with
    xi-insertions and higher terms in Pixton's formula of the double ramification cycle::

        sage: from admcycles import DR_cycle
        sage: g=0; mu = [11,4,-8,-2,-5,-2]; A = [a+1 for a in mu]
        sage: n = len(mu); adddeg = 1
        sage: D = DR_cycle(g,A,rpoly=True,d=g+adddeg,chiodo_coeff=True)
        sage: v = vector(QQ,[a[adddeg] for a in D.basis_vector()])
        sage: S = Strataclass(g,1,mu,xi_power=adddeg)
        sage: print(v); print(-S.basis_vector())
        (0, 0, -4, 7, 2, 4, 2, 0, -1, 0, 0, 0, 0, 2, 0, 2)
        (0, 0, -4, 7, 2, 4, 2, 0, -1, 0, 0, 0, 0, 2, 0, 2)

    We can use the function to compute spin stratum class, with or without the assumption of the
    conjecture of spin Pixton formula::

        sage: cl1=Strataclass(2,1,(8,-4,-2),spin=True)
        sage: cl1.basis_vector()
        (-1107/2, 369/2, -246, -552, -899/2, 288, 590, 807/2, 1254, 1167/2, 1947/2, 613, -793, -1354, 351, -615, -666, 939/2, -563, -2077/2, 1302, 1107/2, -2583/2, 369/2, 21, -165, -181, -369/2, -201/2, 201/2, 551/2, -31/2, -155/2, -203/2, 18, -18, 114, 119/2, -58, 102, -102, -109/2, -76, 142)
        sage: cl2=Strataclass(2,1,(8,-4,-2),spin=True,spin_conj=True)
        sage: cl1==cl2
        True

    If we assume the conjecture above, we can also compute spin strata of meromorphic k-differentials
    for k > 1. Below we check that they restrict under a boundary gluing map as expected::

        sage: from admcycles import StableGraph
        sage: from admcycles.admcycles import prodtautclass
        sage: H = Strataclass(2,3,[10,-4],spin=True,spin_conj=True)
        sage: gamma = StableGraph([1,1],[[1,3],[2,4]],[(3, 4)])
        sage: pb = gamma.boundary_pullback(H)
        sage: H1 = Strataclass(1,3,[10,-10],spin=True,spin_conj=True)
        sage: H2 = Strataclass(1,3,[-4,4],spin=True,spin_conj=True)
        sage: prot = prodtautclass(gamma, protaut=[H1, H2])
        sage: pb.totensorTautbasis(2) == prot.totensorTautbasis(2)
        True
    r1z#mu must be a partition of k*(2g-2).c3s"|]}��|�p|dkVqdS�rN�rOrDrGrrrB�r(zStrataclass.<locals>.<genexpr>�
diffstratacss|]}|ddkVqdS�r1rNrrDrrrrB�r(z!The signature is not of spin typer�>The integer k has to be odd if we want to have spin structure.rrr^css|]}|dkVqdSr_rrDrrrrB�r(css|]}t|t�VqdSrC)�
isinstancer)r$�rcrrrrB�r(css|]}|dkp|dkVqdS)rrNr)r$�arrrrB�r(z:Only residue conditions with coefficients 0,1 implemented.cSs g|]\}}|dkrd|f�qS)rrr)r$rrfrrrr'�r(zStrataclass.<locals>.<listcomp>)Zsig_list�res_condz+Residue conditions only implemented for k=1z0Residue conditions not compatible with virt=TruecSsg|]\}}|dkr|�qSr)r)r$rZmuirrrr'�r()�virtc3s|]}�|ddkVqdS)rrNrr#r%rrrB�r(z/Residue conditions can only be imposed at polesc3s|]}�|ddkVqdS)r�����Nrr#r%rrrB�r(cs g|]}�|ddrd�qS�rr1rr#r%rrr'�r(cs"g|]}t�|dd��qSrjrr#r%rrr'�r(cs(g|] }�d|�d|df�qS)r1rr�r$r/)�maxlegrrr'�r(Fcs$g|]}t�|dd�|��qSr=��Strataclassrk)�genera�outermusrrr'�r(c3s|]}|�VqdSrCrrDrGrrrB�r(cSsi|]\}}|d|�qSr=r)r$rr/rrr�
<dictcomp>�r(zStrataclass.<locals>.<dictcomp>c3s&|]\}}|dd�kr|VqdSr_r�r$rr�rQrrrBr(c3s|]}|�VqdSrCrrDrGrrrBr()�spin)�	bdry_listrt�	spin_conjric3s&|]\}}|dd�kr|VqdSr_rrrrsrrrB$r(c3sZ|]R\}}t|�dkr|dddkr|dd��dfkr|dd�kr|VqdS)r1rrN)rrr)rQ�nrrrB(s��8�c3s|]}|�VqdSrCrrDrGrrrB-r()ruN)1rrr	rL�
ValueError�any�NotImplementedError�fundamental_class�allrdrr�	enumerate�	admcyclesraZgeneralisedstratumZGeneralisedStratum�sig�	SignaturerI�xiZspinstratumZELGT_addspinZto_prodtautclass_spin�pushforwardZto_prodtautclassrJrn�zerorr�boundary_pullback�factor_reconstructr�standard_permutation�inverse�StrataDB�cached�from_vector�rename_legs�KeyErrorr]�popr�Strataboundarysum�vector�	set_cacherP�forgetful_pushforward)&rQrHr&rhrg�xi_power�methodrtrv�RZmeromorphicZfancy_res_condre�XZ	elgtclassZelgtspin�polesZ
num_add_marksZmunewZmarkcounter�legs�edgesr�gammaZoutergZ
outerclassZpullbZordering_permutationZ
ordering_dictZsortmur8Z
ans_preordruZindfind1�resultZsortmuprimeZindfind2Z	preresultr)rQrorHrlr&rwrprrn�s�$
 (�





$
" 

"
rncs^�rrtdd��D��rtd��tdd��D��rNt�fdd��D��rNtd���dkrr�ddkrjtd	���srt�|d
ur�t|d��}g}t��}|D�]�}	dd�|	D��d
d�|	D��g}
|d}�fdd�td|d�D��tt|	��dd
�D]r\}\}
}
}|D]^}�d�	|��|�	|d�|
�	||df�|��|<|��|d<|d7}�qq�t
��|
�}tdd�|	dd
�D��}|�t��dt|��}��r�tdd���
�D���r�q�q�t�d��fdd��dD���d�g}|������fdd�tdt���D�7}|�|�}|||g7}q�|�rF|St|�}|��|Sd
S)aA
    Returns sum of boundary terms in Conjecture A for entries of bdry_list.
    These entries have the format from the output of twistenum, but might be a subset of these.

    INPUT:

        - g (integer): genus

        - k (integer): power of canonical bundle

        - bdry_list (list, default=None): a sublist of all the twisted stable graphs; if not
          specified, it will just use the whole list

        - termsout (bool, default=False): if true, then the output will not be simplified

        - spin (bool, default=False): if true, then compute the spin strata boundary sum

        - spin_conj (bool, default=False): if true, then we will assume the spin Conjecture A
          to be true and the summand will be computed by recursion on this formula

    EXAMPLES::

        sage: from admcycles.stratarecursion import Strataboundarysum
        sage: from admcycles.double_ramification_cycle import DR_cycle
        sage: Strataboundarysum(2,1,(6,-4),spin=True).basis_vector()
        (-139, 46, -109, -99, 219, 194, 174, 136, -318, 91/2, -45/2, -15, -46, -25/2)

    css|]}|ddkVqdSrbrrDrrrrBWr(z$Strataboundarysum.<locals>.<genexpr>z"This signature is not of spin typecss|]}|dkVqdSr_rrDrrrrBYr(c3s|]}��|�VqdSrCr`rDrGrrrBYr(zAThe boundary sum with spin should not be called by such signaturerr1rcNcSsg|]}|d�qSr)rr2rrrr'gr(z%Strataboundarysum.<locals>.<listcomp>cSsg|]}t|d��qSr=)rPr2rrrr'hr(csi|]}|�|d�qSr=rr#r%rrrqlr(z%Strataboundarysum.<locals>.<dictcomp>rcSs g|]\}}}|D]}|�qqSrr)r$r-�	twistvect�Irrrr'vr(css|]\}}|ddkVqdSrbr)r$r-�yrrrrByr(csg|]}�|�qSrrrA)rXrrr'|r(�rtrvc	s6g|].}t�|d��fdd��|D���d��qS)rcsg|]}�|��qSrrrA)rHrXrrr'}r(z0Strataboundarysum.<locals>.<listcomp>.<listcomp>r�rmr7)rorHr�rtrvrXrrr'}s�)ryrxr|rzr]rrrPr}rrr� automorphism_number_fixing_twist�itemsrn�boundary_pushforwardrL�simplify)rQrHr&ru�termsoutrtrvZresulttermsrwZvdatar�rlr8r-r�r�Z
bdry_graph�coeffZ	verttermsZ	bdry_termr�r)rorHr�r&rtrvrXrr�9sX(
"*�
r�cCstd��dS)NzQStrataDB is just an internal database for strata classes, use Strataclass instead)rz)rQrHr&rrrr��sr�cs(|���|��}t��fdd�|D��S)ab
    Return number of automorphisms of gr leaving the twist I on gr invariant.

    EXAMPLES::

        sage: from admcycles import StableGraph
        sage: from admcycles.stratarecursion import automorphism_number_fixing_twist
        sage: gr = StableGraph([0,0],[[1,2,3],[4,5,6]],[(1,2),(3,4),(5,6)])
        sage: twist = {i:0 for i in range(7)}
        sage: automorphism_number_fixing_twist(gr,twist)
        8
        sage: twist[1] = 1
        sage: automorphism_number_fixing_twist(gr,twist)
        2
        sage: twist[2] = 1
        sage: automorphism_number_fixing_twist(gr,twist)
        4
    cs(g|] �t��fdd��D��rd�qS)c3s"|]}��|��|kVqdSrCr)r$�h)r�rQrrrB�r(z>automorphism_number_fixing_twist.<locals>.<listcomp>.<genexpr>r)r|)r$�r��	halfedgesrsrr'�r(z4automorphism_number_fixing_twist.<locals>.<listcomp>)r��leg_automorphism_groupr)�grr��Grr�rr��sr�)Frrr^FF)NFFF)'�__doc__�collections.abcr�copyrrM�sage.misc.miscr�sage.combinat.integer_vectorr�sage.combinat.partitionr�sage.misc.misc_cr�sage.rings.allr	�sage.misc.cachefuncr
�sage.combinat.words.wordr�sage.functions.otherr
�stable_graphrZ#admcycles.double_ramification_cyclerZadmcycles.diffstrata.sigr~Z'admcycles.diffstrata.generalisedstratumZ admcycles.diffstrata.spinstratum�tautological_ringrrrr]rnr�r�r�rrrr�<module>s6&x
R
Q