Beispiel #1
0
def parse_polynomial(poly_str):
    try:
        tokens = tokenise(poly_str)
        terms = []
        var_list = set()
        term = parse_term(tokens)
        while term != None:
            terms.append(term)
            var_list = var_list.union(term["var_list"])
            term = parse_term(tokens)

        var_list = list(var_list)
        poly_ring = om.OMApplication(
            poly_ring_sym, [int_ring] +
            [om.OMVariable(var_name) for var_name in list(var_list)])
        om_terms = []
        for term in terms:
            args = []
            args.append(om.OMInteger(term["index"]))
            for i in range(0, len(var_list)):
                if var_list[i] not in term:
                    args.append(om.OMInteger(0))
                else:
                    args.append(om.OMInteger(term[var_list[i]]))
            om_terms.append(om.OMApplication(term_sym, args))
        sdmp = om.OMApplication(sdmp_sym, om_terms)
        return om.OMApplication(dmp_sym, [poly_ring, sdmp])
    except Exception as e:
        print(e)
        print("Please enter a valid polynomial")
        return None
Beispiel #2
0
def signature(name, cd, symbol_sets=None, min=None, max=None):
    if isinstance(symbol_sets, list):
        n = len(symbol_sets)
        if min is None:
            min = om.OMInteger(n)
        else:
            assert min <= n, "Too few parameters"
            min = om.OMInteger(min)
        assert max is None or max == n, "Too many parameters"
        max = om.OMInteger(n)
        symbol_sets = om.OMApplication(om.OMSymbol('list', cd='list1'),
                                       symbol_sets)
    else:
        min = om.OMInteger(0 if min is None else min)
        max = om.OMSymbol('infinity',
                          cd='nums1') if max is None else om.OMInteger(max)
        if symbol_sets is None:
            symbol_sets = om.OMSymbol('symbol_set_all', cd='scscp2')
    return _apply('signature', [om.OMSymbol(name, cd), min, max, symbol_sets])
Beispiel #3
0
 def get_signature(self, data):
     print(colored(str(data), "blue"))
     if data.arguments[0].name == "groebner":
         sig_sym = om.OMSymbol("signature", "scscp2")
         func_sym = om.OMSymbol("groebner", "singular")
         zero_sym = om.OMInteger(0)
         infinity_sym = om.OMSymbol("infinity", "nums1")
         all_set_sym = om.OMSymbol("symbol_set_all", "scscp2")
         return om.OMApplication(sig_sym, [func_sym, zero_sym, infinity_sym, all_set_sym])
     return om.OMApplication(om.OMSymbol("symbol_set", "scscp2"), [])
Beispiel #4
0
 def __openmath__(self):
     return om.OMInteger(1)
def retrieve_int(name):
    return om.OMInteger(int(RunSingularCommand(name + ";")[1][:-1]))
Beispiel #6
0
def ZZ_to_OM(integer):
    return om.OMInteger(int(integer))
Beispiel #7
0

def run(query, host="127.0.0.1", port=26134):
    """ Evaluates a query on a MitM server """
    xml = encoder.encode_xml(query.getQuery())

    client = None
    result = None
    try:
        client = SCSCPCLI(host, port=port)
        res = client.heads.mitm_transient.mitmEval(
            [query.getQuery(), Systems.SageEval._toOM()], timeout=100000000)
        return hack.to_python(res)
    finally:
        if client:
            client.quit()


converter = convert_pickle.PickleConverter()  # TODO: Use the MitM converter
from sage.rings.integer import Integer
converter._basic_converter.register_to_openmath(Integer,
                                                lambda i: om.OMInteger(int(i)))

Systems = helpers.CDBaseHelper("http://opendreamkit.org/", converter).Systems
lmfdb = qmt.UseSystemHelper("http://www.lmfdb.org/db", "lmfdb", converter)

smglom = helpers.CDBaseHelper("http://mathhub.info/MitM/smglom", converter)
algebra = smglom / "algebra"

smglom = helpers.CDBaseHelper("http://mathhub.info/MitM/smglom", converter)
mitm = helpers.CDBaseHelper("http://mathhub.info/MitM", converter)