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

��c)�@sxddlmZddlmZmZddlmZddlZddlm	Z	m
Z
mZ		ddd	�Zdd
d�Z
dd
�Zdd�Zdd�ZdS)�)�QQ)�matrix�vector)�block_matrixN�)�list_strata�generating_indices�pullback_matrixFcsP|�|�}t|�}|��|}ttd|�}	g}
|dk}�dur\|s\|r)|�|�}n|�|�}tt|j|j	|��}
|j
|||
d�}t|	g|ggdd�}	|
�fdd�|D�7}
|	��|k}|dur�|s�|j
��fdd�t|j|j	d	�D�}t|�dkr�|d��d	kr�|�d�}|�|�|D]/}t|j|j	||d
�}t|	g|ggdd�}	|
t||�j|dd��7}
|	��|k}|r�|s�nq�|du�r|�s|�|d�D]7\}}�|||��}|dur�tt|	gt�fd
d�|D�g�ggdd�}	|
�|�|	��|k}|�r|�snq�|�std��z
|	�tt|
��}Wnt�y!td��w|�||�S)a`
    Identify a tautological class in degree d by specifying its
    intersection pairing with classes in complementary degree
    and/or its pullback under boundary gluing morphisms.

    INPUT::

        - tautring (TautologicalRing) : ring containing the class that
          is to be identified

        - d (integer): degree of the class

        - pairfunction (function, optional): function taking classes in
          complementary degree and returning the intersection product with
          the desired class

        - pullfunction (function, optional): function taking stable graphs
          with at most two vertices and returning the prodtautclass obtained
          by pulling back the desired class under the associated boundary
          gluing map

        - kappapsifunction (function, optional): function taking as arguments
          a list, dictionary and TautologicalClass (giving a polynomial in
          kappa and psi-classes) and returning the intersection product of
          the desired class with this polynomial (or None)

        - check (bool, default = False) : whether to use FZ relations to
          verify that intersection numbers/pullbacks are consistent with
          known tautological relations

    EXAMPLES::

        sage: from admcycles.identify_classes import identify_class
        sage: from admcycles import TautologicalRing
        sage: R = TautologicalRing(2, 1)
        sage: cl = 3 * R.psi(1) -2 * R.kappa(1)
        sage: def pairf(a):
        ....:     return (a * cl).evaluate()
        sage: cl2 = R.identify_class(1, pairfunction = pairf)
        sage: cl == cl2
        True
        sage: def pullf(gamma):
        ....:     return gamma.boundary_pullback(cl)
        ....:
        sage: cl3 = R.identify_class(1, pullfunction=pullf)
        sage: cl == cl3
        True

    Here is some code to reconstruct the class 42*psi_1 on Mbar_0,6 from its intersection
    numbers with psi-monomials (which have an explicit formula). Note that the associated
    function kpfun is allowed to return None if kappa-classes show up::

        sage: R = TautologicalRing(0,6)
        sage: def kpfun(kap, psi, cl):
        ....:     if kap:
        ....:         return None
        ....:     b = vector(ZZ,[psi.get(i,0) for i in range(1,7)])+vector([1,0,0,0,0,0])
        ....:     return 42*factorial(3)/prod(factorial(bi) for bi in b)
        ....:
        sage: cl4 = R.identify_class(1, kappapsifunction=kpfun)
        sage: cl4 == 42*R.psi(1)
        True

    TESTS::

        sage: R = TautologicalRing(2, 1)
        sage: def bad_pairf(a):
        ....:     return (a * cl).evaluate() if not (a - R.kappa(3)).is_empty() else 0
        sage: R.identify_class(1, pairfunction = bad_pairf, check=True)
        Traceback (most recent call last):
        ...
        ValueError: intersection numbers or pullbacks are not consistent with FZ relations
    rN)�basis�	ind_dcompF)�	subdividecsg|]}�|��qS�r
)�.0�a)�pairfunctionr
�>/home/user/Introduction lectures/admcycles/identify_classes.py�
<listcomp>b�z"identify_class.<locals>.<listcomp>csg|]	}|���s|�qSr
)�vanishes)r�gam)�modulir
rrgs
�r)�bdryT��vecoutcsg|]}|����qSr
��evaluate)r�c)�clr
rr{szLIntersection numbers and/or pullbacks are not enough to determine this classzFintersection numbers or pullbacks are not consistent with FZ relations)r
�len�socle_degreerr�
generators�tupler�_g�_n�pairing_matrixr�rank�_modulir�	num_verts�pop�appendr	�list�totensorTautbasis�kappa_psi_polynomials�
ValueError�solve_rightr�from_basis_vector)Ztautring�dr�pullfunction�kappapsifunction�check�gens�ngens�d_dual�M�vZrank_sufficientZ	gens_dualr�inters�graphsZirrgraphrZpulls�kappa�psi�intnum�wr
)rrrr�identify_class	sb
K


��*
��r?cCs�tj�|||�}tj�|||�}tj�||d�}g}|s&tt|�|d�}|D]H}||d}	g}
d}|	t|�dkrHt||	��j�d}n	t||	j�d}|D]}|�||�}
|
|
j	|dd�g7}
qSt
|
�}||g7}q(|S)a<
    Compute the pullback matrices of given degree d and list of
    boundary stratum.

    INPUT::


        - ind_list (list): the list of indices of the boundary stratum,
                           0 indicates the first nontrivial graph
                           appearing in the generator
                           list of degree d tautological classes

    EXAMPLES::

    sage: from admcycles.identify_classes import Pullback_Matrices
    sage: from admcycles import TautologicalRing
    sage: Pullback_Matrices(1, 2, 1)
    [
    [1]  [1]
    [0], [1]
    ]

    rNrTr)�	admcycles�tautgensr�rangerr*�standard_markings�_terms�boundary_pullbackr+r)�g�nr0Zind_list�L1ZListgen1�L2�M_listr�b�M0�Q�i�Tr7r
r
r�Pullback_Matrices�s&rPc	s�d|d||}tj�|||��tj�|||��tj�|||�}g}�D]���fdd�|D�}|�|�q&tt|��t|���d�t���fdd�tdt	���D��}|S)a�
    Identify a tautological class in degree d by specifying
    its intersection pairing
    with classes in complementary degree.

    INPUT::


        - list_evaluate (list) : the list of intersection numbers

        - list_dual_classes (list): a list of classes of dual codimension
                                    one wants to compute the intersection
                                    (the program will complete the list
                                    such that one obtain a full rank matrix)


    EXAMPLES::

        sage: from admcycles.identify_classes import solve_perfect_pairing
        sage: from admcycles import TautologicalRing
        sage: R = TautologicalRing(1,3)
        sage: cl = R.psi(1) -2 * R.kappa(1)
        sage: def pairf(a):
        ....:     return (a * cl).evaluate()
        sage: cl2 = solve_perfect_pairing(1, 3, 1,
        ....: [pairf(x) for x in R.generators(2)])
        sage: cl == cl2
        True

    �csg|]
}��|���qSr
r)r�X)�genrNr
rr�sz)solve_perfect_pairing.<locals>.<listcomp>rc3�$�|]
}�|��|VqdS�Nr
�rrN��SolrS�indr
r�	<genexpr>���"z(solve_perfect_pairing.<locals>.<genexpr>)
r@rrAr)r*r�
solve_left�sumrBr)	rFrGr0Z
list_evaluater6Zgen_dualZ	M_intpairZintersection_vector�outputr
)rXrSrNrYr�solve_perfect_pairing�s$r_cs�d�d|d|krtd��fdd�|D�}t||����fdd�|D�}t||��tj�||���tj�||���t���fdd�tt���D��}|S)a3
    Identify a tautological class in degree d by specifying its pullback
    under boundary gluing morphisms.

    INPUT::


        - bdiv_indices(list) : the list of indices of boundary
                               stratum(the first nontrivial graph in
                               tautgen list will be indexed
                               by 0) to which we will pullback
        - pullback_classes(list) : the list of pullbacks of the tautological
                                    class with respect to the bdiv listed

    EXAMPLES::

        sage: from admcycles.identify_classes import solve_clutch_pullback
        sage: from admcycles import TautologicalRing
        sage: R = TautologicalRing(1,3)
        sage: stgraphs = [list(x._terms)[0] for x in R.generators(1)[4:]]
        sage: cl = R.psi(1) -2 * R.kappa(1)
        sage: def pullf(gr):
        ....:     return gr.boundary_pullback(cl)
        sage: cl2 = solve_clutch_pullback(1, 3, 1, range(len(stgraphs)),
        ....: [pullf(gr) for gr in stgraphs])
        sage: cl == cl2
        True

    �z/ It may not work because the codim is too largecsg|]	}|j�dd��qS)Tr)r+)rrO)r0r
rr
sz)solve_clutch_pullback.<locals>.<listcomp>csg|]}�|�qSr
r
rV)�ListMr
rrrc3rTrUr
rVrWr
rrZr[z(solve_clutch_pullback.<locals>.<genexpr>)	�printrP�SolveMultLinr@rrAr]rBr)rFrGr0Zbdiv_indicesZpullback_classes�ListVZListM_1r^r
)rarXr0rSrYr�solve_clutch_pullback�s
"rec	s�|d���t�fdd�|D��sJ�g}g}|D]
}|t|���7}qt|���}|D]}|t|�7}q,t|g�}|�|�}t|�}t|d�}|S)Nrc3s�|]	}|���kVqdSrU)�nrows)rrM��dimr
rrZs�zSolveMultLin.<locals>.<genexpr>)rf�allr*�	transposerr\r)	rardZNewMZNewVrM�W�result�LrXr
rgrrcs

rc)NNNFrU)�sage.rings.rational_fieldr�sage.matrix.constructorrr�sage.matrix.specialrZadmcycles.admcyclesr@rrr	r?rPr_rercr
r
r
r�<module>s
�
1-+