Skip to content

Assertion error in certain Khuri-Makdisi small arithmetic operations #40237

@vincentmacri

Description

@vincentmacri
Contributor

Steps To Reproduce

Attempting to add certain divisors in the km_small Jacobian implementation results in an assertion error. I have not encountered this with the km_medium or km_large models. I've found examples for function fields over GF(2), GF(3), GF(5), and GF(7) so I don't think it's an issue caused by small characteristic.

Here is an example where this bug occurs:

K = GF(2)
Kx.<x> = FunctionField(K)
t = polygen(Kx)
F.<y> = Kx.extension(t^3 + (x^2 + x + 1)*t^2 + (x^3 + x + 1)*t + x^5 + x^4)

O = F.maximal_order()
Oinf = F.maximal_order_infinite()

D1 = -5 * O.ideal(x, y).divisor() + O.ideal(x + 1, y^2 + y + 1).divisor() + O.ideal(x^3 + x^2 + 1, y + x + 1).divisor()
D2 = Oinf.ideal(1/x, y/x^2 + 1).divisor() - 5 * O.ideal(x, y).divisor() + O.ideal(x^4 + x^3 + 1, y + x).divisor()

assert D1.degree() == 0
assert D2.degree() == 0

print(D1)  # -5*Place (x, y) + Place (x + 1, y^2 + y + 1) + Place (x^3 + x^2 + 1, y + x + 1)
print(D2)  # Place (1/x, 1/x^2*y + 1) - 5*Place (x, y) + Place (x^4 + x^3 + 1, y + x)

J = F.jacobian('km_small')
print(J.base_divisor())  # 5*Place(x, y)

JD1 = J(D1)
JD2 = J(D2)
JD1 + JD2

The last line gives the following error:

...
File "sage/rings/function_field/khuri_makdisi.pyx", line 174, in sage.rings.function_field.khuri_makdisi.KhuriMakdisi_base.mu_preimage (build/cythonized/sage/rings/function_field/khuri_makdisi.c:6896)
    assert not expected_codim or r == expected_codim
AssertionError

Expected Behavior

The divisors D1 and D2 in the above example are degree 0 divisors of the function field. So they are in the Jacobian group (or rather, have representatives in the Jacobian group). Since this is mathematically valid input, we should be able add these two Jacobian elements without encountering an error.

Actual Behavior

An assertion error is encountered on mathematically valid input.

Additional Information

Tagging @kwankyu as he implemented the Khuri-Makdisi arithmetic.

Environment

  • OS: Fedora 42
  • Sage Version: 10.6

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
    I have read the documentation and troubleshoot guide

Activity

added theissue type on Jun 9, 2025
added a commit that references this issue on Jun 13, 2025
63b5554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @vincentmacri

      Issue actions

        Assertion error in certain Khuri-Makdisi small arithmetic operations · Issue #40237 · sagemath/sage