Exemplo n.º 1
0
    def get_rand_sigs(pol_lst, num_tries=10):
        '''
        Parameters
        ----------
        pol_lst : list<MARing.R>   
            A list of polynomials in the ring "MARing.R".
        
        num_tries : int 
            A positive integer. 
                
        Returns
        -------
        list
            Returns a sorted list of pairs of integers that represent 
            signatures of random quadratic forms in the ideal generated 
            by "pol_lst". For each subset of the list of quadrics, this 
            method computes "num_tries" of random linear combination of 
            this subset of quadratic forms. 
        '''
        q_lst = [pol for pol in pol_lst if pol.total_degree() == 2]

        sig_lst = []
        for s_lst in sage_Subsets(len(q_lst)):
            for i in range(num_tries):
                quad = sum(
                    [sage_QQ.random_element() * q_lst[s - 1] for s in s_lst])
                if quad in sage_QQ:
                    continue
                sig = MARing.get_sig(quad)
                if sig not in sig_lst:
                    sig_lst += [sig]
                    MATools.p('sig =', sig, '\t\t quad =', quad)
                    MATools.p('\t\t sub_lst', [q_lst[s - 1] for s in s_lst])

        return sorted(sig_lst)
Exemplo n.º 2
0
    def get_aut_P8(c_lst):
        '''
        The double Segre surface S is isomorphic to P^1xP^1.
        The pair (A,B) of 2x2 matrices denotes an automorphism 
        of P^1xP^1. We compute the representation of this 
        automorphism in P^8 by using the parametrization as 
        provided by ".get_pmz_lst". Since we consider the 
        2x2 matrices up to multiplication by a constant, 
        it follows that the automorphism group is 6-dimensional.        
        Formally, this method computes Sym^2(A)@Sym^2(B) 
        where @ denotes the tensor product (otimes in tex).        
        
        Parameters
        ---------- 
        c_lst: list<MARing.FF>
            A list of length 8 with elements c0,...,c7 in "MARing.FF". 
            We assume that the pair of matrices 
                ( [ c0 c1 ]   [ c4 c5 ] ) = (A,B) 
                ( [ c2 c3 ] , [ c6 c7 ] )                                                                                                                                                         
            represent an automorphism of P^1xP^1.
                                                             
        Returns
        -------
        sage_matrix
            A 9x9 matrix defined over "MARing.FF", which represents a 
            (parametrized) automorphism of P^8 that preserves the 
            double Segre surface S.                                                 
        '''
        # obtain parametrization in order to compute Sym^2(?)@Sym^2(?)
        #
        pmz_lst = DSegre.get_pmz_lst()

        # compute automorphisms double Segre surface
        #
        c0, c1, c2, c3, c4, c5, c6, c7 = c_lst
        x0, x1, y0, y1 = ring('x0,x1,y0,y1')
        s, t, u, w = ring('s,t,u,w')  # coordinates of P^1xP^1
        dct1 = {}
        dct1.update({s: c0 * x0 + c1 * x1})
        dct1.update({t: c2 * x0 + c3 * x1})
        dct1.update({u: c4 * y0 + c5 * y1})
        dct1.update({w: c6 * y0 + c7 * y1})
        dct2 = {x0: s, x1: t, y0: u, y1: w}
        spmz_lst = [pmz.subs(dct1).subs(dct2) for pmz in pmz_lst]

        # compute matrix from reparametrization "spmz_lst"
        # this is a representation of element in Aut(P^1xP^1)
        #
        mat = []
        for spmz in spmz_lst:
            row = []
            for pmz in pmz_lst:
                row += [spmz.coefficient(pmz)]
            mat += [row]
        mat = sage_matrix(MARing.FF, mat)

        MATools.p('c_lst =', c_lst)
        MATools.p('mat =\n' + str(mat))

        return mat
Exemplo n.º 3
0
    def get_invariant_q_lst(c_lst):
        '''                        
        Parameters
        ---------- 
        c_lst : list 
            A list of length 9 with elements c0,...,c8 
            in the subring in QQ(k)  of "MARing.FF". 
            The matrix                             
                [ c0 c1 c2 ]
            M = [ c3 c4 c5 ]
                [ c6 c7 c8 ]                                                       
            represents---for each value of k---an 
            automorphism of P^2. If we set k:=0 then 
            "c_lst" must correspond to the identity matrix: 
            [ 1,0,0, 0,1,0, 0,0,1 ]. If M is not normalized
            to have determinant 1 then the method should be 
            taken with care (see doc. ".get_c_lst_lst_dct"). 
                                                                                     
        Returns
        -------
        list<MARing.R>
            A list of generators of an ideal J in the subring 
            QQ[q0,...,q6] of "MARing.R". 
               
            Each point p in the zeroset V(J), when substituted in the matrix 
                ".get_qmat()",
            defines a quadratic form in the ideal 
                ".get_ideal_lst()"
            that is preserved by a 1-parameter subgroup H,                                         
            where H is the representation of M in P^5 (see ".get_aut_P5()"). 
            Thus H corresponds to a 1-parameter subgroup of Aut(P^5), 
            such that each automorphism preserves the Veronese surface 
            in projective 5-space P^5.
               
        '''
        # get representation of 1-parameter subgroup in Aut(P^5)
        #
        H = Veronese.get_aut_P5(c_lst)

        # consider the tangent vector of the curve H at the identity
        #
        k = ring('k')
        D = MARing.diff_mat(H, k).subs({k: 0})
        MATools.p('D =\n' + str(D))

        # Note that if we differentiate the condition
        # A=H.T*A*H on both sides, evaluate k=0, then
        # we obtain the condition D.T * A + A * D=0.
        # Here A denotes the matrix of a quadratic form
        # in the ideal of the double Segre surface S.
        #
        A = Veronese.get_qmat()
        Z = D.T * A + A * D
        iq_lst = [iq for iq in Z.list() if iq != 0]
        MATools.p('qi_lst =', iq_lst)

        return iq_lst
Exemplo n.º 4
0
    def get_aut_P5(c_lst):
        '''
        Parameters
        ----------
        c_lst : list   
            A list of length 9 with elements c0,...,c8 in "MARing.FF". 
            The matrix                             
                [ c0 c1 c2 ]
            M = [ c3 c4 c5 ]
                [ c6 c7 c8 ]
            represents an automorphism of P^2.
                                                             
        Returns
        -------
        sage_matrix
            This method returns a 6x6 matrix defined over "MARing.FF",
            which represents a (parametrized) automorphism of P^5
            that preserves the Veronese surface V. 
                                                  
        Notes
        -----
        The Veronese surface V is isomorphic to P^2.
        The automorphism M of P^2 is via the parametrization 
        ".get_pmz_lst" represented as an automorphism of P^5. 
        Algebraically this is the symmetric tensor Sym^2(M).
        '''
        # obtain parametrization in order to compute Sym^2(M)
        #
        pmz_lst = Veronese.get_pmz_lst()

        # compute automorphisms double Segre surface
        #
        c0, c1, c2, c3, c4, c5, c6, c7, c8 = c_lst
        x0, x1, x2 = ring('x0,x1,x2')
        s, t, u = ring('s,t,u')  # coordinates of P^2
        dct1 = {}
        dct1.update({s: c0 * x0 + c1 * x1 + c2 * x2})
        dct1.update({t: c3 * x0 + c4 * x1 + c5 * x2})
        dct1.update({u: c6 * x0 + c7 * x1 + c8 * x2})
        dct2 = {x0: s, x1: t, x2: u}
        spmz_lst = [pmz.subs(dct1).subs(dct2) for pmz in pmz_lst]

        # compute matrix from reparametrization "spmz_lst"
        # this is a representation of element in Aut(P^1xP^1)
        #
        mat = []
        for spmz in spmz_lst:
            row = []
            for pmz in pmz_lst:
                row += [spmz.coefficient(pmz)]
            mat += [row]
        mat = sage_matrix(MARing.FF, mat)

        MATools.p('c_lst =', c_lst)
        MATools.p('mat =\n' + str(mat))

        return mat
    def test__p(self):

        MATools().filter(None)
        assert MATools().p('Hello world!') != None

        MATools().filter(['another_class.py'])
        assert MATools().p(
            'No output since called from another class.') == None

        MATools().filter_unset()
        assert MATools().p('Filter is disabled so output this string.') != None

        MATools().filter_reset()
        assert MATools().p('Filter is enabled again so do not output.') == None

        MATools().filter(['test_class_ma_tools.py'])
        assert MATools().p('Only output if called from this class') != None
Exemplo n.º 6
0
    def get_invariant_qf(c_lst_lst, exc_idx_lst=[]):
        '''
        Computes quadratic forms in the ideal of the
        double Segre surface that are invariant under
        a given subgroup of Aut(P^1xP^1). 
        
        Parameters
        ----------        
        c_lst_lst : list<list<MARing.FF>>  
            A list of "c_lst"-lists.
            A c_lst is a list of length 8 with elements 
            c0,...,c7 in QQ(k), 
            where QQ(k) is a subfield of "MARing.FF".
            If we substitute k:=0 in the entries of 
            "c_lst" then we should obtain the list:
                [1,0,0,1,1,0,0,1].                                                                      
            A c_lst represents a pair of two matrices:                                
                ( [ c0 c1 ]   [ c4 c5 ] ) 
                ( [ c2 c3 ] , [ c6 c7 ] )                                   
            with the property that 
                c0*c3-c1*c2!=0 and c4*c7-c5*c6!=0.
            If the two matrices are not normalized
            to have determinant 1 then the method should be 
            taken with care (it should be checked that the
            tangent vectors at the identity generate the 
            correct Lie algebra).                                             
        
        exc_idx_lst : list<int>
            A list of integers in [0,8].                                     
        
        Returns
        -------
        A list of quadratic forms in the ideal of (a projection of) 
        the double Segre surface S:
            ".get_ideal_lst( exc_idx_lst )"
        such that the quadratic forms are invariant 
        under the automorphisms of S as defined by "c_lst_lst"
        and such that the quadratic forms generate the module of  
        all invariant quadratic forms. Note that Aut(S)=Aut(P^1xP^1).   
        '''

        # for verbose output
        #
        mt = MATools()
        sage_set_verbose(-1)

        # initialize vectors for indeterminates of "MARing.R"
        #
        x = MARing.x()
        q = MARing.q()
        r = MARing.r()

        # obtain algebraic conditions on q0,...,q19
        # so that the associated quadratic form is invariant
        # wrt. the automorphism defined by input "c_lst_lst"
        #
        iq_lst = []
        for c_lst in c_lst_lst:
            iq_lst += DSegre.get_invariant_q_lst(c_lst, exc_idx_lst)
        iq_lst = list(MARing.R.ideal(iq_lst).groebner_basis())

        # solve the ideal defined by "iq_lst"
        #
        sol_dct = MARing.solve(iq_lst, q)

        # substitute the solution in the quadratic form
        # associated to the symmetric matrix qmat.
        #
        qmat = DSegre.get_qmat(exc_idx_lst)
        qpol = list(sage_vector(x).row() * qmat *
                    sage_vector(x).column())[0][0]
        sqpol = qpol.subs(sol_dct)
        mt.p('sqpol   =', sqpol)
        mt.p('r       =', r)
        assert sqpol.subs({ri: 0 for ri in r}) == 0
        iqf_lst = []  # iqf=invariant quadratic form
        for i in range(len(r)):
            coef = sqpol.coefficient(r[i])
            if coef != 0:
                iqf_lst += [coef]
        mt.p('iqf_lst =', iqf_lst)

        return iqf_lst
Exemplo n.º 7
0
    def solve(pol_lst, var_lst):
        '''
        Parameters
        ----------
        pol_lst : list<MARing.R> 
            List of polynomials in "MARing.R" 
            but not in the variables r0,r1,....
    
        var_lst : list
            List of variables  "MARing.R". 
            Length of list should be at most 20.
        
        Returns
        -------
        dict
            A dictionary of parametrized solutions of the  
            zeroset of the ideal generated by the polynomials in 
            "pol_lst". The solutions are parametrized in terms of r0,r1,... 
        
        Note
        ----
            We call Sage "solve" method, but reset the indeterminates
            to be r0,...,r19, otherwise for each new call new 
            r# variables are introduced. The "reset" and "restore"
            functions do not work. See also:
              <https://ask.sagemath.org/question/23719/how-to-reset-variables/>              
            The indeterminates of the "solve" method are either c or r. 
        '''
        # cast to Sage symbolic ring SR and
        # call solve.
        #
        spol_lst = [sage_SR(str(pol)) for pol in pol_lst]
        svar_lst = [sage_SR(str(var)) for var in var_lst]
        dct = sage_solve(spol_lst, svar_lst, solution_dict=True)[0]
        MATools.p('pol_lst =', pol_lst)
        MATools.p('var_lst =', var_lst)
        MATools.p('dct     =', dct)

        # construct a list with integers i such
        # ri is occuring in the "dct" dictionary.
        #
        end_char_lst = []
        s = str(dct)
        if pol_lst == []:  # ci are used instead of ri
            s = s.replace('c', 'r')
        rn_lst = []
        i = 0
        while i < len(s):

            if s[i] == 'r':
                i += 1
                n = ''
                while s[i] in [str(j) for j in range(10)]:
                    n += s[i]
                    i += 1

                # store end character: eg. 'r10}' OR 'r10*' OR 'r10,' OR 'r10 '
                if s[i] not in end_char_lst:
                    end_char_lst += [s[i]]

                if int(n) not in rn_lst:
                    rn_lst += [int(n)]
            i += 1

        MATools.p('end_char_lst =', end_char_lst)
        MATools.p('rn_lst       =', rn_lst)

        # replace each occurence of r<i> with r<t>
        # where t=0,...,t19
        #
        t = 0
        for n in sorted(rn_lst):

            #
            # note that we want to prevent for example:
            #     r1-->r0 but also r10-->r00, for this
            # reason we consider the character which indicates
            # the end of the r-variable string so that:
            #    'r1}'-->'r0}', 'r1,'-->'r0,', 'r10'--->'r10'
            #
            for end_char in end_char_lst:
                s = s.replace('r' + str(n) + end_char, 'r' + str(t) + end_char)
            t += 1

        # cast to solution dictionary with
        # keys and values in "MARing.R"
        #
        sol_dct = ring(s)
        MATools.p('sol_dct =', sol_dct)

        return sol_dct
    def test__tool_dct(self):

        ma = MATools()
        ma2 = MATools()

        # watch out to not use the default file name
        # otherwise it might take long to load the data
        test_fname = 'test_tools'
        key = 'test__tool_dct'

        dct = ma.get_tool_dct(fname=test_fname)
        dct[key] = True
        ma.save_tool_dct(fname=test_fname)

        assert key in ma.get_tool_dct(fname=test_fname)
        assert key in ma2.get_tool_dct(fname=test_fname)

        ma.set_enable_tool_dct(False)
        assert key not in ma.get_tool_dct(fname=test_fname)
        assert key not in ma2.get_tool_dct(fname=test_fname)

        ma.set_enable_tool_dct(True)
        assert key in ma.get_tool_dct(fname=test_fname)
        assert key in ma2.get_tool_dct(fname=test_fname)
Exemplo n.º 9
0
def usecase__invariant_quadratic_forms_veronese(case):
    '''
    Let G be a subgroup of Aut(P^2).
    Compute the vectors space of real G-invariant quadratic forms in
    the ideal of the Veronese surface in projective 5-space P^5
    obtained by the method "Veronese.get_ideal_lst()".
                   
    The real structure is specified in terms of an involution. We have
    two equivalent choices for the involution. Either we can use 
    "Veronese.get_change_basis()" or we consider the usual complex 
    conjugation. 
        
    See the code below for a description of the cases.

    Parameters
    ----------
    case : str
        A string representing the name of a group G.
        The string should be either:
            ['1a','1b','sl3','so3']                 
    '''
    #
    # We initialize 1-parameter subgroups of SL3, whose tangent vectors at the
    # identity generate Lie subalgebras of sl3(RR) and sl3(CC).
    #
    sl3_lst = h1, h2, a1, a2, a3, b1, b2, b3 = Veronese.get_c_lst_lst_dct(
    )['SL3(C)']
    so3_lst = r1, r2, r3 = Veronese.get_c_lst_lst_dct()['SO3(R)']

    if case == '1a':
        descr = '''
                This example shows that there exists a quadric of signature 
                (1,5) in the ideal of the Veronese surface, with the involution
                that induces the involution (a,b)|->(b,a) on the lattice polygon
                of the Veronese surface. 
                '''
        infoG = 'trivial group'
        c_lst_lst = []
        involution = 'diagonal'

    elif case == '1b':
        descr = '''
                This example shows that there exists a quadric of signature 
                (1,5) in the ideal of the Veronese surface, with the involution
                that induces the identity (a,b)|->(a,b) on the lattice polygon
                of the Veronese surface. 
                '''
        infoG = 'trivial group'
        c_lst_lst = []
        involution = 'identity'

    elif case == 'sl3':
        descr = '''
                This example shows that there exists no quadric that is invariant 
                under the full automorphism group of the Veronese surface.
                '''
        infoG = 'SL3(C):  [h1, h2, a1, a2, a3, b1, b2, b3]'
        c_lst_lst = sl3_lst
        involution = 'identity'

    elif case == 'so3':
        descr = '''
                This example shows that there exists a quadric of signature 
                (1,5) in the ideal of the Veronese surface, such that this 
                quadric is invariant under the group SO(3)               
                '''
        infoG = 'SO3(R):  [r1, r2, r3]'
        c_lst_lst = so3_lst
        involution = 'identity'

    else:
        raise ValueError('Unknown case:', case)

    #
    # compute vector space of invariant quadratic forms
    #
    iq_lst = Veronese.get_invariant_qf(c_lst_lst)

    if involution == 'diagonal':
        iq_lst = Veronese.change_basis(iq_lst)
        iq_lst = MARing.replace_conj_pairs(iq_lst)
    elif involution == 'identity':
        pass
    else:
        raise ValueError('Incorrect involution: ', involution)

    #
    # computes signatures of random quadrics in
    # the vector space of invariant quadratic forms.
    #
    sig_lst = MARing.get_rand_sigs(iq_lst, 5)

    #
    # output results
    #
    while descr != descr.replace('  ', ' '):
        descr = descr.replace('  ', ' ')
    MATools.p('\n' + 80 * '-')
    MATools.p('case        :', case)
    MATools.p('description :\n', descr)
    MATools.p('G           :', infoG)
    MATools.p('involution  :', involution)
    MATools.p('G-invariant quadratic forms:')
    for iq in iq_lst:
        MATools.p('\t', iq)
    MATools.p('random signatures:')
    MATools.p('\t', sig_lst)
    for sig in sig_lst:
        if 1 in sig:
            MATools.p('\t', sig)
    MATools.p('\n' + 80 * '-')
Exemplo n.º 10
0
def usecase__classification(cache=True):
    '''
    Prints a classification of quadratic forms
    that contain some fixed double Segre surface S
    in projective 8-space, such that the quadratic
    form is invariant under subgroup of Aut(S).
    We consider subgroups equivalent, if they are
    real conjugate in Aut(P^1xP^1).
    
    Parameters
    ----------
    cache : bool
        If True, then the cached result is used,
        otherwise the output is recomputed. The 
        computation may take about 9 hours.
    '''
    key = 'usecase__classification'
    if cache and key in MATools.get_tool_dct():
        MATools.p(MATools.get_tool_dct()[key])
        return

    out = ''
    for involution in ['identity', 'leftright', 'rotate']:

        for c_lst_lst in DSegre.get_c_lst_lst_lst():

            #
            # compute invariant quadratic forms
            #
            iq_lst = DSegre.get_invariant_qf(c_lst_lst)
            iq_lst = DSegre.change_basis(iq_lst, involution)
            iq_lst = MARing.replace_conj_pairs(iq_lst)

            #
            # computes signatures of random quadrics in
            # the vector space of invariant quadratic forms.
            #
            sig_lst = []
            if 'I' not in str(iq_lst):
                sig_lst = MARing.get_rand_sigs(iq_lst, 10)

            tmp = ''
            tmp += '\n\t' + 10 * '-'
            tmp += '\n\t involution        =' + involution
            tmp += '\n\t group             =' + DSegre.to_str(c_lst_lst)
            tmp += '\n\t invariant ideal   = <'
            for iq in iq_lst:
                sig = ''
                if 'I' not in str(iq):
                    sig = MARing.get_sig(iq)
                tmp += '\n\t\t' + str(iq) + '\t\t' + str(sig)
            tmp += '\n\t\t >'
            tmp += '\n\t random signatures ='
            tmp += '\n\t\t ' + str(sig_lst)
            for sig in sig_lst:
                if 1 in sig:
                    tmp += '\n\t\t' + str(sig)
            tmp += '\n\t' + 10 * '-'

            # output obtained info to screen
            MATools.p(tmp)

            # add to output string
            out += tmp

    # cache output string
    MATools.get_tool_dct()[key] = out
    MATools.save_tool_dct()
Exemplo n.º 11
0
def usecase__horn_and_spindle_cyclides():
    '''    
    We consider the following cyclides with monomial
    parametrization determined by the following lattice 
    polygons:  
    
        [  *  ]           [  *  ]
        [* * *]           [  *  ]
        [  *  ]           [* * *]
        
     spindle cyclide    horn cyclide   
     leftright          leftright  
     (2,4,3)            (2,4,3)
       
    and 'leftright' involution act as a modular involution
    with vertical symmetry axis. We use the following numbering 
    (see DSegre.get_ideal_lst() and DSegre.change_basis()):
               
        [8 3 5]
        [2 0 1]
        [6 4 7]                
    '''
    if True:
        #
        # G-invariant quadratic forms for spindle cyclide
        # (see usecase__invariant_quadratic_forms('243ss')):
        #
        # x0^2 - x3*x4
        # x0^2 - x1^2 - x2^2
        #
        # We send x3 |--> a*(x4-x3)
        #         x4 |--> a*(x4+x3)
        #         where a=sqrt(1/2)
        # followed by sending: x4 |--> x0, x0 |--> x4

        a = ring('a')
        xv = x0, x1, x2, x3, x4 = ring('x0,x1,x2,x3,x4')
        y0, y1, y2, y3 = ring('y0,y1,y2,y3')
        m34 = sage_matrix(MARing.R,
                          [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0],
                           [0, 0, 0, -a, a], [0, 0, 0, a, a]])
        m04 = sage_matrix(MARing.R,
                          [[0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0],
                           [0, 0, 0, 1, 0], [1, 0, 0, 0, 0]])
        m = m34 * m04
        v = sage_vector(xv)
        g1 = ring('x0^2 - x3*x4')
        g2 = ring('x0^2 - x1^2 - x2^2')
        mat1 = sage_invariant_theory.quadratic_form(
            g1, xv).as_QuadraticForm().matrix()
        mat2 = sage_invariant_theory.quadratic_form(
            g2, xv).as_QuadraticForm().matrix()
        ng1 = v.row() * m.T * mat1 * m * v.column()
        ng2 = v.row() * m.T * mat2 * m * v.column()
        G1 = sage_SR(str(ng1[0])).subs({sage_SR('a'): 1 / sage_sqrt(2)})
        G2 = sage_SR(str(ng2[0])).subs({sage_SR('a'): 1 / sage_sqrt(2)})

        S = sage_PolynomialRing(sage_QQ,
                                sage_var('x0,x1,x2,x3,x4,y0,y1,y2,y3'))
        x0, x1, x2, x3, x4, y0, y1, y2, y3 = S.gens()
        G1 = sage__eval(str(G1), S.gens_dict())
        G2 = sage__eval(str(G2), S.gens_dict())
        assert G1 in S
        assert G2 in S
        smap = [y0 - (x0 - x3), y1 - x1, y2 - x2, y3 - x4]
        prj_lst = S.ideal([G1, G2] + smap).elimination_ideal(
            [x0, x1, x2, x3, x4]).gens()
        eqn = str(prj_lst[0].subs({y0: 1})).replace('y1', 'x').replace(
            'y2', 'y').replace('y3', 'z')

        MATools.p(80 * '-')
        MATools.p('SPINDLE CYCLIDE')
        MATools.p(80 * '-')
        MATools.p('We define a projective automorphism m:P^4--->P^4')
        MATools.p('\t a   = 1/sqrt(2)')
        MATools.p('\t m34 =', list(m34))
        MATools.p('\t m04 =', list(m04))
        MATools.p('\t m = m34 * m04 =', list(m))
        MATools.p('\t det(m) =', m.det())
        MATools.p('\t v |--> m*v =', v, '|-->', m * v)
        MATools.p(
            'Generators of ideal of cyclide in quadric of signature [1,4]:')
        MATools.p('\t g1 =', g1)
        MATools.p('\t g2 =', g2)
        MATools.p('Generators of ideal of cyclide in S^3 after applying m:')
        MATools.p('\t G1 =', G1)
        MATools.p('\t G2 =', G2)
        MATools.p('\t G2-2*G1 =', G2 - 2 * G1)
        MATools.p('Stereographic projection to circular quadratic cone:')
        MATools.p('\t smap    =', smap, '(stereographic projection map)')
        MATools.p('\t prj_lst =', prj_lst)
        MATools.p('\t eqn     =', eqn)
        MATools.p(80 * '-' + 2 * '\n')

    if True:
        #
        # G-invariant quadratic forms for horn cyclides
        # (see usecase__invariant_quadratic_forms('243st')):
        #
        # x0^2 - x3*x4
        # x4^2 - x6^2 - x7^2
        #

        a = ring('a')
        xv = x0, x3, x4, x6, x7 = ring('x0,x3,x4,x6,x7')
        y0, y1, y2, y3 = ring('y0,y1,y2,y3')
        m = sage_matrix(MARing.R,
                        [[0, 0, a, 0, 0], [0, 1, 0, 0, 0], [-1, -1, 0, 0, 0],
                         [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]])
        v = sage_vector(xv)
        g1 = ring('x0^2 - x3*x4')
        g2 = ring('x4^2 - x6^2 - x7^2')
        mat1 = sage_invariant_theory.quadratic_form(
            g1, xv).as_QuadraticForm().matrix()
        mat2 = sage_invariant_theory.quadratic_form(
            g2, xv).as_QuadraticForm().matrix()
        ng1 = v.row() * m.T * mat1 * m * v.column()
        ng2 = v.row() * m.T * mat2 * m * v.column()
        G1 = sage_SR(str(ng1[0])).subs({sage_SR('a'): 1 / sage_sqrt(2)})
        G2 = sage_SR(str(ng2[0])).subs({sage_SR('a'): 1 / sage_sqrt(2)})

        S = sage_PolynomialRing(sage_QQ,
                                sage_var('x0,x3,x4,x6,x7,y0,y1,y2,y3'))
        x0, x3, x4, x6, x7, y0, y1, y2, y3 = S.gens()
        G1 = sage__eval(str(G1), S.gens_dict())
        G2 = sage__eval(str(G2), S.gens_dict())
        assert G1 in S
        assert G2 in S
        smap = [y0 - (x0 + x3), y1 - x4, y2 - x7, y3 - x6]
        prj_lst = S.ideal([G1, G2] + smap).elimination_ideal(
            [x0, x3, x4, x6, x7]).gens()
        eqn = str(prj_lst[0].subs({y0: 1})).replace('y1', 'x').replace(
            'y2', 'y').replace('y3', 'z')

        MATools.p(80 * '-')
        MATools.p('HORN CYCLIDE')
        MATools.p(80 * '-')
        MATools.p('We define a projective automorphism m:P^4--->P^4')
        MATools.p('\t a   = 1/sqrt(2)')
        MATools.p('\t m =', list(m))
        MATools.p('\t det(m) =', m.det())
        MATools.p('\t v |--> m*v =', v, '|-->', m * v)
        MATools.p(
            'Generators of ideal of cyclide in quadric of signature [1,4]:')
        MATools.p('\t g1 =', g1)
        MATools.p('\t g2 =', g2)
        MATools.p('Generators of ideal of cyclide in S^3 after applying m:')
        MATools.p('\t G1 =', G1)
        MATools.p('\t G2 =', G2)
        MATools.p('\t G2-2*G1 =', G2 - 2 * G1)
        MATools.p('Stereographic projection to circular cylinder:')
        MATools.p('\t smap    =', smap, '(stereographic projection map)')
        MATools.p('\t prj_lst =', prj_lst)
        MATools.p('\t eqn     =', eqn)
        MATools.p(80 * '-' + 2 * '\n')
Exemplo n.º 12
0
def usecase__toric_invariant_celestials():
    '''  
    We output the ideal and Hilbert polynomial of all possible 
    toric projections of the double Segre  surface. For 
    each generator in the ideal we consider its coordinate
    change such that the real structure corresponding 
    to leftright/rotate becomes complex conjugation
    (see "DSegre.change_basis()").
    
    Notes
    -----
    Suppose that G is the group of toric automorphisms
    of the double Serge surface X in P^8. The double 
    Segre surface admits a monomial parametrization. 
    The exponents corresponds to lattice points on 
    a square. We number these lattice points as follows:
    
        8  3  5
        2  0  1  
        6  4  7
    
    These exponents correspond to following parametrization:  
    
    (s,u) |-->
        (1:s:s^{-1}:u:u^{-1}:s*u:s^{-1}*u^{-1}:s*u^{-1}:s^{-1}*u)
        =
        (x0:x1:x2:x3:x4:x5:x6:x7:x8)
    
    The identity component of the toric automorphisms G are 
    represented by 9x9 diagonal matrices and are isomorphic to the 
    group SO(2)xSO(2). The vector space of G-invariant quadratic 
    forms in the ideal of the double Segre surface in P^8 is 
    generated by:
    
      V = < x0^2 - x7^2 - x8^2, 
            x0^2 - x5^2 - x6^2, 
            x0^2 - x3^2 - x4^2, 
            x0^2 - x1^2 - x2^2 >
    
    A quadric Q in V of signature (1,n+1) corresponds to 
    a celestial Y in the unit sphere S^n as follows: S^n
    is up to real projective equivalence defined by the
    projection of Q from its singular locus. The celestial
    Y is the image of the double Segre surface X under this 
    projection. Note that the singular locus of Q can intersect
    X such that Y is of lower degree. Another possibility is
    that the projection restricted to X is 2:1 such that the 
    degree of Y is 4. It turns out that projection of X with
    center singular locus of Q is toric in the sense we obtain
    ---up to projective equivalence---a parametrization by
    omitting monomials in the parametrization above. Using the 
    labels 0-8 of the lattice points in the square we consider
    the following projections, where P denotes the list of 
    monomials which are omitted:
    
    Q = (x0^2-x7^2-x8^2)+(x0^2-x5^2-x6^2)  
    P = [1,2,3,4]
    
    Q = (x0^2-x7^2-x8^2)+(x0^2-x3^2-x4^2)  
    P = [1,2,5,6]
    
    Q = (x0^2-x7^2-x8^2)+(x0^2-x1^2-x2^2)  
    P = [1,2,3,4]
    
    Q = (x0^2-x7^2-x8^2)+(x0^2-x3^2-x4^2)  
    P = [1,2,5,6]        
                             
    '''

    # ideal of the double Segre surface in
    # coordinate ring R of P^8
    #
    IX = DSegre.get_ideal_lst()
    R = sage_PolynomialRing(sage_QQ, ['x' + str(i) for i in range(9)])
    IX = R.ideal(sage__eval(str(IX), R.gens_dict()))

    # we consider all possible projections from the singular
    # locus of Q (see OUPUT documention).
    #
    prevP_lst = []
    for P1 in [[1, 2], [3, 4], [5, 6], [7, 8]]:
        for P2 in [[1, 2], [3, 4], [5, 6], [7, 8]]:

            # construct indices for projection map
            #
            P = sorted(list(set(P1 + P2)))
            if P not in prevP_lst:
                prevP_lst += [P]
            else:
                continue

            # project the double Segre surface wrt. P
            #
            J = IX.elimination_ideal(
                [sage__eval('x' + str(i), R.gens_dict()) for i in P])

            # in order to get the right Hilbert polynomial we coerce into smaller ring
            #
            RP = sage_PolynomialRing(
                sage_QQ, ['x' + str(i) for i in range(9) if i not in P])
            JP = RP.ideal(sage__eval(str(J.gens()), RP.gens_dict()))
            hpol = JP.hilbert_polynomial()

            # output info
            #
            if not JP.is_zero():
                MATools.p(10 * '-')
                MATools.p(
                    'set of i such that <xi for i in P> is the ideal of the center of projection:'
                )
                MATools.p('\t', P)
                MATools.p('projection of double Segre surface wrt. P:')
                for gen in JP.gens():
                    MATools.p('\t', gen)
                    for involution in ['leftright', 'rotate']:
                        MATools.p('\t\t', involution, '\t',
                                  DSegre.change_basis([ring(gen)], involution))
                MATools.p('hilbert polynomial ((deg/dim!)*t^(dim)+...):')
                MATools.p('\t', hpol)
Exemplo n.º 13
0
def usecase__invariant_quadratic_forms(case):
    '''
    Let G be a subgroup of Aut(P^1xP^1) determined by the case-parameter.
    We output the vectors space of real G-invariant quadratic forms in
    the ideal of a (projection of) the double Segre surface
    obtained by the method:
        "DSegre.get_ideal_lst( exc_idx_lst )"                   
    The real structure is specified in terms of an involution. See 
        "DSegre.change_basis()" 
    for the specification of involutions.
    We also output signatures of random G-invariant quadratic forms. 

    Parameters
    ----------
    case : str
        Three numerical characters, which characterize
        the projection of a double Segre surface in S^n.
        For example 
            '078', 
        means 
            #families=0, #n=7, #degree=8.
        If several examples are considered for the same
        triple then we extend with a character in [a-z].
        These are currently implemented cases:
            ['087','287','365','265s','265t','443','243ss','243st']

    Notes
    -----
    See the source code below for a description of each of the cases of
    projections of double Segre surfaces that we consider.                
                    
    '''

    #
    # obtain 1-parameter subgroups whose tangent vectors at the
    # identity generates the Lie algebra sl(2)
    #
    t, q, s, r, e, T = DSegre.get_gens_sl2()

    #
    # "involution" is in { 'identity', 'leftright', 'rotate', 'diagonal' }
    #
    # "c_lst_lst" represents a subgroup G of Aut(P^1xP^1) as a list of
    # 1-parameter subgroups that generate G.
    #
    if case == '087':
        descr = '''
                This example shows that there exists a 
                quadric of signature (4,5) that is invariant
                under the full automorphism group of S.
                '''
        infoG = 'SL(2) x SL(2):  [t + e, q + e, s + e, e + t, e + q, e + s ]'
        exc_idx_lst = []
        c_lst_lst = [t + e, q + e, s + e, e + t, e + q, e + s]
        involution = 'identity'

    elif case == '287':
        descr = '''
                This example shows quadrics of signatures (1,8), 
                (1,6) and (1,4) in the ideal of the double Segre
                surface, that are invariant under a 2-dimensional 
                group of toric Moebius automorphisms.         
                '''
        infoG = 'SO(2) x SO(2): [ s + e, e + s ]'
        exc_idx_lst = []
        c_lst_lst = [s + e, e + s]
        involution = 'rotate'

    elif case == '365':
        descr = '''
                This example shows that there exists a smooth sextic Del Pezzo 
                surface in S^5 that is invariant under a 2-dimensional group 
                of toric Moebius automorphisms.
                '''
        infoG = 'SO(2) x SO(2): [ s + e, e + s ]'
        exc_idx_lst = [5, 6]
        c_lst_lst = [s + e, e + s]
        involution = 'rotate'

    elif case == '265s':
        descr = ''' 
                This example shows that there exists a singular sextic 
                Del Pezzo surface in S^5 that is invariant under a 1-dimensional 
                group of toric Moebius automorphisms. Random signatures of type 
                [1,n+1] with n>=3 found so far are: [1,4], [1,6].

                If we extend the group with [e+s] then we obtain a quadric of 
                signature [1,4]; this is the horn cyclide case with 
                generators: x0^2 - x3*x4,  x0^2 - x1^2 - x2^2,  
                
                If we extend the group with [e+t] then we obtain a quadric of 
                signature [1,4]; this is the spindle cyclide case with 
                generators: x0^2 - x3*x4,  x4^2 - x6^2 - x7^2.                                  
                '''
        infoG = 'SO(2): [ s + e ]'
        exc_idx_lst = [5, 8]
        c_lst_lst = [s + e]
        involution = 'leftright'

    elif case == '265t':
        descr = ''' 
                This example indicates that there does not exists a singular 
                sextic Del Pezzo surface in S^5 that is invariant under a 
                1-dimensional group of Moebius translations. Random signatures 
                of type [1,n+1] with n>=3 found so far are: [1,4].                                
                '''
        infoG = 'SE(1): [ e + t ]'
        exc_idx_lst = [5, 8]
        c_lst_lst = [e + t]
        involution = 'leftright'

    elif case == '443':
        descr = '''
                This example shows that the ring cyclide in S^3 admits a 
                2-dimensional family of toric Moebius automorphisms. 
                '''
        infoG = 'SO(2) x SO(2): [ s + e, e + s ]'
        exc_idx_lst = [5, 6, 7, 8]
        c_lst_lst = [s + e, e + s]
        involution = 'rotate'

    elif case == '243ss':
        descr = ''' 
                This example shows that the spindle cyclide in S^3 admits a 
                2-dimensional family of Moebius automorphisms.
                '''
        infoG = 'SO(2) x SX(1): [ s + e, e + s ]'
        exc_idx_lst = [5, 6, 7, 8]
        c_lst_lst = [s + e, e + s]
        involution = 'leftright'

    elif case == '243st':
        descr = ''' 
                This example shows that the horn cyclide in S^3 admits a 
                2-dimensional family of Moebius automorphisms.
                '''
        infoG = 'SO(2) x SE(1): [ s + e, e + t ]'
        exc_idx_lst = [1, 2, 5, 8]
        c_lst_lst = [s + e, e + t]
        involution = 'leftright'

    else:
        raise ValueError('Unknown case: ', case)

    #
    # compute vector space of invariant quadratic forms
    #
    iq_lst = DSegre.get_invariant_qf(c_lst_lst, exc_idx_lst)
    iq_lst = DSegre.change_basis(iq_lst, involution)
    iq_lst = MARing.replace_conj_pairs(iq_lst)

    #
    # computes signatures of random quadrics in
    # the vector space of invariant quadratic forms.
    #
    sig_lst = MARing.get_rand_sigs(iq_lst, 10)

    #
    # output results
    #
    while descr != descr.replace('  ', ' '):
        descr = descr.replace('  ', ' ')
    mat_str = str(sage_matrix([[8, 3, 5], [2, 0, 1], [6, 4, 7]]))
    new_mat_str = mat_str
    for ei in exc_idx_lst:
        new_mat_str = new_mat_str.replace(str(ei), ' ')
    for ei in range(0, 9):
        new_mat_str = new_mat_str.replace(str(ei), '*')

    MATools.p('\n' + 80 * '-')
    MATools.p('case        :', case)
    MATools.p('description :\n', descr + '\n' + mat_str + '\n\n' + new_mat_str)
    MATools.p('G           :', infoG)
    MATools.p('exc_idx_lst :', exc_idx_lst)
    MATools.p('involution  :', involution)
    MATools.p('G-invariant quadratic forms:')
    for iq in iq_lst:
        MATools.p('\t', iq)
    MATools.p('random signatures:')
    MATools.p('\t', sig_lst)
    for sig in sig_lst:
        if 1 in sig:
            MATools.p('\t', sig)
    MATools.p('\n' + 80 * '-')
Exemplo n.º 14
0
def usecase__invariant_quadratic_forms_experiment():
    '''
    We output for given subgroup G of Aut(P^1xP^1),
    the vectors space of real G-invariant quadratic forms in
    the ideal of a (projection of) the double Segre surface
    obtained by the method:
        "DSegre.get_ideal_lst( exc_idx_lst )"
    
    This method is for experimentation with different
    groups and real structures. The parameters are set 
    in the code. 
    '''
    #
    # obtain 1-parameter subgroups whose tangent vectors at the
    # identity generates the Lie algebra sl(2)
    #
    t, q, s, r, e, T = DSegre.get_gens_sl2()

    #
    # set input parameters
    #
    exc_idx_lst = []
    c_lst_lst = [s + e, e + t]
    involution = 'leftright'
    MATools.p('exc_idx_lst =', exc_idx_lst)
    MATools.p('c_lst_lst   =', DSegre.to_str(c_lst_lst))
    MATools.p('involution  =', involution)
    MATools.p('---')

    #
    # compute vector space of real invariant quadratic forms.
    #
    iq_lst = DSegre.get_invariant_qf(c_lst_lst, exc_idx_lst)
    MATools.p('invariant quadratic forms =\n\t', iq_lst)
    iq_lst = DSegre.change_basis(iq_lst, involution)
    MATools.p('change basis              =\n\t', iq_lst)
    iq_lst = MARing.replace_conj_pairs(iq_lst)
    MATools.p('replaced conjugate pairs  =\n\t', iq_lst)
Exemplo n.º 15
0
    MATools.p('G           :', infoG)
    MATools.p('involution  :', involution)
    MATools.p('G-invariant quadratic forms:')
    for iq in iq_lst:
        MATools.p('\t', iq)
    MATools.p('random signatures:')
    MATools.p('\t', sig_lst)
    for sig in sig_lst:
        if 1 in sig:
            MATools.p('\t', sig)
    MATools.p('\n' + 80 * '-')


if __name__ == '__main__':

    MATools.start_timer()
    mod_lst = []
    mod_lst += ['__main__.py']
    MATools.filter(mod_lst)  # output only from specified modules
    # MATools.filter( None )  # uncomment for showing all debug output
    sage_set_verbose(
        -1)  # surpresses warning message for slow for Groebner basis.

    ###############################################
    # (un)comment usecases for this package below #
    ###############################################

    for case in ['087', '287', '365', '265s', '265t', '443', '243ss', '243st']:
        usecase__invariant_quadratic_forms(case)

    usecase__invariant_quadratic_forms_experiment()
Exemplo n.º 16
0
    def get_invariant_qf(c_lst_lst):
        '''
        Parameters
        ----------    
        c_lst_lst : list 
            A list of "c_lst"-lists.
            A c_lst is a list of length 9 with elements 
            c0,...,c8 in the subring in QQ(k)  of "MARing.FF". 
            The matrix                         
                [ c0 c1 c2 ]
            M = [ c3 c4 c5 ]
                [ c6 c7 c8 ]                                                         
            represents---for each value of k---an 
            automorphism of P^2. If we set k:=0 then 
            "c_lst" must correspond to the identity matrix: 
            [ 1,0,0, 0,1,0, 0,0,1 ]. If M is not normalized
            to have determinant 1 then the method should be 
            taken with care (see doc. ".get_c_lst_lst_dct").         
        
        Returns
        -------
        list<MARing.R>
            A list of quadratic forms in the ideal of the Veronese surface V
            (see ".get_ideal_lst()"), such that the quadratic forms are 
            invariant under the automorphisms of V as defined by "c_lst_lst"
            and such that the quadratic forms generate the module of  
            all invariant quadratic forms. Note that Aut(V)=Aut(P^2).   
        '''

        # for verbose output
        #
        mt = MATools()

        # initialize vectors for indeterminates of "MARing.R"
        #
        x = MARing.x()[:6]
        q = MARing.q()[:6]
        r = MARing.r()[:6]

        # obtain algebraic conditions on q0,...,q19
        # so that the associated quadratic form is invariant
        # wrt. the automorphism defined by input "c_lst_lst"
        #
        iq_lst = []
        for c_lst in c_lst_lst:
            iq_lst += Veronese.get_invariant_q_lst(c_lst)
        iq_lst = list(MARing.R.ideal(iq_lst).groebner_basis())

        # solve the ideal defined by "iq_lst"
        #
        sol_dct = MARing.solve(iq_lst, q)

        # substitute the solution in the quadratic form
        # associated to the symmetric matrix qmat.
        #
        qmat = Veronese.get_qmat()
        qpol = list(sage_vector(x).row() * qmat *
                    sage_vector(x).column())[0][0]
        sqpol = qpol.subs(sol_dct)
        mt.p('sqpol   =', sqpol)
        mt.p('r       =', r)
        assert sqpol.subs({ri: 0 for ri in r}) == 0
        iqf_lst = []  # iqf=invariant quadratic form
        for i in range(len(r)):
            coef = sqpol.coefficient(r[i])
            if coef != 0:
                iqf_lst += [coef]
        mt.p('iqf_lst =', iqf_lst)

        return iqf_lst