Esempio n. 1
0
def number_field_jump(info):
    query = {'label_orig': info['jump']}
    try:
        parse_nf_string(info, query, 'jump', name="Label", qfield='label')
        # we end up parsing the string twice, but that is okay
        F1, _, _ = input_string_to_poly(info['jump'])
        # we only use the output of input_string_to_poly with single-letter variable names
        if F1 and len(str(F1.parent().gen())) == 1 and F1.list() != db.nf_fields.lookup(query['label'], 'coeffs'):
            flash_info(r"The requested field $\Q[{}]/\langle {}\rangle$ is isomorphic to the field below, but uses a different defining polynomial.".format(str(F1.parent().gen()), latex(F1)))
        return redirect(url_for(".by_label", label=query['label']))
    except ValueError:
        return redirect(url_for(".number_field_render_webpage"))
Esempio n. 2
0
def genus2_lookup_equation(input_str):
    # retuns:
    # label, C_str
    # None, C_str when it couldn't find it in the DB
    # "", input_str when it fails to parse
    # 0, C_str when it fails to start magma
    R = PolynomialRing(QQ, "x")
    y = PolynomialRing(R, "y").gen()

    def read_list_coeffs(elt):
        if not elt:
            return R(0)
        else:
            return R([int(c) for c in elt.split(",")])

    if ZLLIST_RE.fullmatch(input_str):
        input_str = input_str.strip('[').strip(']')
        fg = [read_list_coeffs(elt) for elt in input_str.split('],[')]
    elif ZLIST_RE.fullmatch(input_str):
        input_str = input_str.strip('[').strip(']')
        fg = [read_list_coeffs(input_str), R(0)]
    else:
        input_str = input_str.strip('[').strip(']')
        fg = [R(list(coeff_to_poly(elt))) for elt in input_str.split(",")]
    if len(fg) == 1:
        fg.append(R(0))

    C_str_latex = fr"\({latex(y**2 + y*fg[1])} = {latex(fg[0])}\)"
    try:
        C = magma.HyperellipticCurve(fg)
        g2 = magma.G2Invariants(C)
    except TypeError:
        raise ValueError(f'{C_str_latex} invalid genus 2 curve')
    g2 = str([str(i) for i in g2]).replace(" ", "")
    for r in db.g2c_curves.search({"g2_inv": g2}):
        eqn = literal_eval(r["eqn"])
        fgD = [R(eqn[0]), R(eqn[1])]
        D = magma.HyperellipticCurve(fgD)
        # there is recursive bug in sage
        if str(magma.IsIsomorphic(C, D)) == "true":
            if fgD != fg:
                flash_info(f"The requested genus 2 curve {C_str_latex} is isomorphic to the one below, but uses a different defining polynomial.")
            return r["label"], ""
    return None, C_str_latex