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

��c%C�@sZdZddlZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZdd	l
mZdd
lmZddlmZddlmZd
dlmZd>dd�Zdd�Zdd�Zd?dd�Zd@dd�Zdd�Zdd�Zdd�ZdAd d!�ZdBd"d#�Z d$d%�Z!d&d'�Z"d(d)�Z#dCd*d+�Z$d,d-�Z%d.d/�Z&d0d1�Z'dDd2d3�Z(d4d5�Z)d6d7�Z*d8d9�Z+d:d;�Z,d<d=�Z-dS)Ez
Double ramification cycle
�N)�copy)�IntegerVectors��bernoulli_polynomial)�	factorial)�exp)�QQ)�PowerSeriesRing��list_strata)�StableGraph��DR_cycle�)�TautologicalRingFc
 s2|dur$|dur d�d�n|}|durT��fdd�td�d�d�D�}|durddd�}�durtdd	���
dur�d
d��
�dur�dd
��g}
|D�]|\��|t�����
�
dkr�q�g}���}�fdd�t|�D��dd��D�}
���}�fdd�t|�D���fdd�t|�D������
�fdd�t|�D�������
�
�fdd�|D������
fdd����D���fdd����D���fdd��D���fdd����D�}|��fdd����D��|du�r�t�
d�}n|t����g}|D�]�}t|||
d�D�]؉��fdd�t|�D�}tj|�D�]��g�i�	t|�D]<���	��d��	���fdd�t
�����D���qV��fdd��D�}�	�fdd��D�}|D]}|�|||9<�q����D]�\}}��|\}}t||�}|�|�||f�
||�	|||�	|d�|��|��	|9<��|\}}t||�}|�||��|��	|9<�q�|D]}|���q���|�}|��|���s@||���9}|�	|��q@�q�q|	d k�r|
�	t|��q�|
|7}
q�|	�r&|
St|
�SdS)!a�Returns the (possibly mixed-degree) tautological class obtained by summing over graphs gamma,
    inserting vertex-, leg- and edgeterms.

    INPUT:

    - ``decgraphs`` -- list or generator; entries of decgraphs are pairs (gamma,dec) of a StableGraph
      gamma and some additional combinatorial structure dec associated to gamma

    - ``globalfact`` -- function; globalfact(gamma,dec) gets handed the parameters gamma,dec as arguments and gives out a number that is multiplied with the corresponding term in the graph sum; default is 1

    - ``vertterm`` -- function; ``vertterm(gv,nv,maxdeg, **kwargs)`` takes arguments local genus gv and number of legs nv
      and maxdeg gets handed the parameters gamma,dec,v as optional keyworded arguments and gives out a
      tautological class on Mbar_{gv,nv}; the class is assumed to be of degree at most maxdeg,
      if deg is given, the class is exactly of degree deg

    - ``legterm`` -- function; ``legterm(gv,nv,i,maxdeg, **kwargs)`` similar to vertterm, except input is
      gv,nv,i,maxdeg where i is number of marking on Mbar_{gv,nv} associated to leg
      gamma, dec and origleg (number of leg in outer graph) given as keyworded arguments

    - ``edgeterm`` -- function; edgeterm(maxdeg,**kwargs) takes keyworded arguments gamma,dec,e,maxdeg
      it gives a generating series s in x0,x1 such that the insertion at edge
      e=(h0,h1) is given by s(psi_h0, psi_h1)

    - ``termsout`` -- parameter; if termsout=False, return sum of all terms
      if termsout = 'coarse', return tuple of terms, one for each pair (gamma,dec)
      if termsout = 'fine', return tuple of terms, one for each pair (gamma,dec) and each distribution
      of cohomological degrees to vertices and half-edges
    N�cs&g|]}t��|�D]}|df�qqS�Nr
)�.0Zednum�gr)�g�n��7/home/user/Introduction lectures/admcycles/graph_sum.py�
<listcomp>8s�zgraph_sum.<locals>.<listcomp>rcSsdS�Nrr��a�brrr�
globalfact;szgraph_sum.<locals>.globalfactc[st||���Sr�r�fundamental_class)�gv�nv�maxdeg�kwargsrrr�vertterm>szgraph_sum.<locals>.verttermc[st||���Srr)r!r"�ir#r$rrr�legtermAszgraph_sum.<locals>.legtermc[sttd|dd�}|��S�N�x0,x1r��default_prec)r	r�one)r#r$�Srrr�edgetermDszgraph_sum.<locals>.edgetermrcs$g|]}��|�t��|��f�qSr)�genera�len�legs�rr&��gammarrrR�cSs g|]\}}d|d|�qS)rr)rrrrrrrSr5cs"i|]}��|�D]
}||�qqSr)r1)r�v�lr3rr�
<dictcomp>Ur5zgraph_sum.<locals>.<dictcomp>cs.i|]&}t��|��D]\}}||d�qqS�r)�	enumerater1)rr6�jr7r3rrr8Vr5cs2i|]*}|��|d�|d���|d��qS)rr)r4�decr6r�rr6)r<r4�gnvect�restdegr%rrr8Zr5cs@i|]8}|���|d��|d�|���|d��qS)rr)r4r<�origlegrr2)r<r4r>�indexdicr'r?�vertdicrrr8[s�&�c	si|]}|����|d��qS))r4r<�er�rrC)r<r.r4r?rrr8]r5cs*i|]"\}}||f�||f�����qSr)�parent�gens�r�h0�h1��etermsrrr8^r5csi|]}|�|���qSr)�coefficientsrDrJrrr8_r5cs"i|]\}}|�||fd�qS�rrrG��varlistrrr8`r5cs"i|]\}}|�||fd�qSr9rrGrNrrr8ar5)�outercs(g|] }t�|t��|��d��qSr9)rr0r1r=)�degdistr4rrrkr5cs"i|]\}}|��|d�qSr9r)rr&r7)�choicer6rrr8qr5csg|]}�|��|��qSr��degree_partr=)�vdims�vtermsrrrsr5cs i|]}|�|��|��qSrrSr2)�ldims�ltermsrrr8tr5Zcoarse)�ranger0�edges�numvert�
list_markings�updater�	itertools�product�appendr:r1r�get�psi�simplify�boundary_pushforward�is_empty�sum) rr�	decgraphsrr%r'r.r#�degZtermsoutZtermlistZgammadectermlistr[Zdimvect�markingsZvarxZrdlis�rdegZvertchoicesZ	effvtermsZ	effltermsr&rHrIZgv0Znv0�R0Zgv1Znv1�R1�t�tempresr)rRr<rQr.rKrr4r>rArWr'rXrr?r6rOrUrBr%rVr�	graph_sums�(�

(
&���
*	



rocCs|�d�|�d�kS�Nr�)�vertex)rrrr�DR11_tree_test�srscs�fdd�td|d�D�S)NcsJg|]B}tt|�|d��D]&}tdd||�D]}t|�r2|�q2qqS)rrrq)rY�minrrs)rrrCr�r#rrr�s"�zDR11_trees.<locals>.<listcomp>r)rY)rr#rrur�
DR11_trees�srvc
s|durd|dd}g}t||�D]�}t|���d}tdd�|jD���g}t||dd�D]�}t|j�t|�}t|j�dd�t	�d�|d�D�}t|j
��fdd�t	�d�|d�D�}	|�t|||	��q`|d	d�|D�7}q&t
|d
d��|S)NrrqcSsg|]}t|dg��qSrM)�max�rr;rrrr�r5zDR11_graphs.<locals>.<listcomp>r)�min_partcSsg|]
}|g�qSrrrxrrrr�r5csg|]}|�d|f�qS)rqrrx��maxlegrrr�r5cSsg|]}|df�qSrr)r�gamrrrr�r5cSs|d�|d�S)Nr)�
is_isomorphicrrrr�<lambda>�r5zDR11_graphs.<locals>.<lambda>)rvr0r\rwr1rrr/�listrYrZr`r�
removedups)
rr#�resultrrZgrlistZgdistr/r1rZrrzr�DR11_graphs�s*.r�csl�durdd��t��}t��}t|dd�D]:�t���fdd�t�d|�D��r,����|d8}q,dS)a6
    Remove duplicates in a list ``li`` according to a comparison function.

    This works inplace and modifies ``li``.

    EXAMPLES::

        sage: from admcycles.graph_sum import removedups
        sage: L = [4,6,3,2,4,99,1,3,2]
        sage: removedups(L)
        sage: L
        [6, 4, 99, 1, 3, 2]
    NcSs||kSrrrrrr�comp�szremovedups.<locals>.comp�����c3s |]}����|�VqdSrrrx�r�r&�lirr�	<genexpr>�r5zremovedups.<locals>.<genexpr>r)r0rY�any�pop)r�r�rZcurrnrr�rr��s$
r�cCstd�|��Sr)r�automorphism_number)r4r<rrr�divbyaut�sr�csjt||��|dkrH|d}|d}���}d|j|vrB||S|Snt�fdd�t|d�D��SdS)Nrr4r6rcsg|]}d|��|��qS�r���lambdaclassrx��Rrrr�r5zDR11_vterm.<locals>.<listcomp>�rr r1rfrY�r!r"r#r$r4r6�frr�r�
DR11_vterm�s

r�cKs6ttd|dd�}|��\}}dd||||Sr(�r	rrF)r#r$r-�x0�x1rrr�
DR11_eterm�sr�cKs2|dur|}t|dft||d�ttt|d�|��S�Nrqru)rgrr%r.rh)ror�r�r�r��rrh�kwdsrrr�DR11_sum�sr�ccsBt||�D]2\}}dd�|jD�}tj|�D]}||fVq,q
dS)zg
    Decorate the graphs of DR11_graphs(g) with a choice of half-edge
    at each non-root vertex.
    cSsg|]}d|vr|�qSr9rr=rrrrr5z"DR11_decgraphs.<locals>.<listcomp>N)r�r1r^r_)rr#Zgr0�_�LrRrrr�DR11_decgraphssr�cCs |j�d�}t|d�|��S)Nrr)r/�countrr�)r4r<Z	zerovertsrrr�divbyaut_newsr�csht||��|dkrF|d}|d}���}d|j|vr@d|S|Snt�fdd�t|d�D��SdS)Nrr4r6rr�csg|]}d|��|��qSr�r�rxr�rrrr5z"DR11_vterm_new.<locals>.<listcomp>r�r�rr�r�DR11_vterm_news
r�c	Ks`ttd|dd�}|��\}}|d}|d}d}|D]}||vr6|d7}q6dd|||S)Nr)rr*rCr<rr�)	r#r$r-r�r�rCr<�exr&rrr�DR11_eterm_new"s
r�cKs2|dur|}t|dft||d�ttt|d�|��Sr�)ror�r�r�r�r�rrr�DR11_sum_new0sr�cCst|�}|�|�|S)z�
    Computes the union of dictionaries d1, d2.

    EXAMPLES::

        sage: from admcycles.graph_sum import dicunion
        sage: d1 = {1:2, 3:4}; d2 = {1:2, 4:5};
        sage: dicunion(d1, d2)
        {1: 2, 3: 4, 4: 5}
    )rr])�d1�d2�d3rrr�dicunion9s
r�c	#s�t��}�fdd�t|�D�}td|d|d�D]�}t|||�D]�}|���tj�fdd��D��D]|�t|��fdd�tt���D��������fdd�tt���D��t���fd	d
�t	|�
�|���D��rj|�fVqjqFq6dS)a�
    Returns a generator of pairs (Gamma, w) of pairs of stable graphs Gamma in genus g
    and admissible k-weightings w mod r on Gamma for the weight vector Avector.

    EXAMPLES::

        sage: from admcycles.graph_sum import GammaWlist
        sage: list(GammaWlist(0, (4,-1,-2,-3), 1, 2))
        [([0] [[1, 2, 3, 4]] [], {1: 4, 2: -1, 3: -2, 4: -3}),
         ([0, 0] [[1, 2, 5], [3, 4, 6]] [(5, 6)],
          {1: 4, 2: -1, 3: -2, 4: -3, 5: 0, 6: 0}),
         ([0, 0] [[1, 3, 5], [2, 4, 6]] [(5, 6)],
          {1: 4, 2: -1, 3: -2, 4: -3, 5: 1, 6: 1}),
         ([0, 0] [[1, 4, 5], [2, 3, 6]] [(5, 6)],
          {1: 4, 2: -1, 3: -2, 4: -3, 5: 0, 6: 0})]
    csi|]}|d�|�qSr9rr2)�Avectorrrr8[r5zGammaWlist.<locals>.<dictcomp>rrcsg|]}tt����qSr)rrY�r�h��rrrr_r5zGammaWlist.<locals>.<listcomp>csi|]}�|d�|�qSrMrr2)rZ�wrrr8`r5cs&i|]}�|d��|��qSr9rr2)rZr�r�rrr8ar5c3sH|]@\}}�d|dt|�t�fdd�|D���dkVqdS)rqc3s|]}�|VqdSrrr�)�dicrrr�br5z'GammaWlist.<locals>.<genexpr>.<genexpr>rN)r0rf)rr!Zhev)r��kr�rrr�br5zGammaWlist.<locals>.<genexpr>N)r0rYrrZr^r_r�r]�all�zipr/r1)rr�r�r�rZstdicrCr4r)r�r�rZr�r�r�r�
GammaWlistIs"$(r�cs��fdd�}|S)Ncs0|��|��d}�d�d||��Srp)�	num_edges�	num_vertsr�)r4r�rI�rr�rr�GFgszChiodo_GF.<locals>.GFr)rr�r�rr�r�	Chiodo_GFfsr�cCsNddlm}|dd�|durF|dur2t||�}nt|�}||���S|��S)aF
    Given a tautological class x on Mbar_{g,n} of degree at least 1, returns
    the exponential exp(x) = 1 + x + 1/2*x^2 + ... of x.

    EXAMPLES::

        sage: from admcycles.graph_sum import expclass
        sage: from admcycles import TautologicalRing
        sage: R = TautologicalRing(1, 2)
        sage: expclass(R.psi(1))
        doctest:...: DeprecationWarning: expclass is deprecated. Please use the exp method of TautologicalClass instead
        See https://gitlab.com/modulispaces/admcycles/-/merge_requests/109 for details.
        Graph :      [1] [[1, 2]] []
        Polynomial : 1 + psi_1 + 1/2*psi_1^2

    TESTS::

        sage: from admcycles import TautologicalRing
        sage: R = TautologicalRing(0, 3)
        sage: expclass(R.zero(), 0, 3)
        Graph :      [0] [[1, 2, 3]] []
        Polynomial : 1
    r)�deprecation�mzNexpclass is deprecated. Please use the exp method of TautologicalClass insteadN)�
supersededr�rr)�xrrr�r�rrr�expclassms
r�cs��fdd�}|S)NcsHt||��t���fdd�tdd|d|d�D��}�|���S)Nc3sB|]:}d|dt��|d�||d��|�VqdS�r�rN)r�kappa�r�m)r�r�r�rrr��s�z.Chiodo_vterm.<locals>.vterm.<locals>.<genexpr>rr�rrfrYr)r!r"r#r$�expo�r�r�r�r�vterm�s

�
zChiodo_vterm.<locals>.vtermr)r�r�r�rr�r�Chiodo_vterm�sr�cs�fdd�}|S)Ncs`t||��|d}|d}||�t����fdd�tdd|d|d�D��}�|���S)Nr<r@c3sF|]>}d|dt��|d�||d����|VqdSr�)rrbr�)r��air&r�rrr��s� ��z2Chiodo_legterm.<locals>.legterm.<locals>.<genexpr>rrr�)r!r"r&r#r$r<r@r�r�)r�r�r&rr'�s
�zChiodo_legterm.<locals>.legtermr)r�r'rr�r�Chiodo_legterm�sr�cs�fdd�}|S)Ncst|d}|d}||d�ttd|dd�}|��\��t����fdd�td	|d
�D��}d	t|���S)Nr<rCrr)�r*c3sJ|]B}d|dt��|d�||d�|�|VqdSr�rr�)r��whr�r�rrr��s� ��z1Chiodo_edgeterm.<locals>.eterm.<locals>.<genexpr>rr)r	rrFrfrYr)r#r$r<rCr-r�r�)r�r�r�r�eterm�s�zChiodo_edgeterm.<locals>.etermr)r�r�rr�r�Chiodo_edgeterm�s
r�c
	CsPt|�}t||||�}t||�}t||�}t|�}t|�}	t|||||||	d�S)a
    Computes the mixed-degree class epsilon_* c(-R^* pi_* L) from [JPPZ17]_, Corollary 4.

    This agrees with the corresponding sum of DR_cycles with chiodo_coeff=True, weighted by appropriate powers of r.

    EXAMPLES::

        sage: from admcycles.graph_sum import Chiodo, Chiodo_alt
        sage: g=1; A=(0,0); k=2; r=2;
        sage: (Chiodo_alt(g, A, k, r)-Chiodo(g, r, k, A, 1)).simplify()
        0
        sage: g=1; A=(1,1); k=4; r=3;
        sage: (Chiodo_alt(g, A, k, r)-Chiodo(g, r, k, A, 1)).simplify()
        0
    )rgrr%r'r.)r0r�r�r�r�r�ro)
rr�r�r�rZGWlistr�r�Zltermr�rrr�
Chiodo_alt�s

r�cs:t��}t�����fdd�td�d|d�D��S)Nc
3sB|]:}�d�d|d�|t��|�d�d�VqdS)rqrT)�chiodo_coeff�r_coeffNr
)r�d��Arr�r�r�rrr��r5zChiodo.<locals>.<genexpr>rr)r0rfrY)rr�r�r�r�rrr�r�Chiodo�sr�)NNNNNNNF)N)N)N)N)N)NN).�__doc__r^r�sage.combinat.integer_vectorr�sage.combinat.combinatr�sage.arith.allr�sage.functions.logr�sage.rings.allr�sage.rings.power_series_ringr	Zadmcycles.admcyclesrZadmcycles.stable_graphrZ#admcycles.double_ramification_cycler�tautological_ringrrorsrvr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�<module>sH





	
#