Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomized tests failing for AlgClosure{fqPolyRepField} #2691

Closed
lgoettgens opened this issue Aug 17, 2023 · 15 comments · Fixed by Nemocas/Nemo.jl#1579
Closed

Randomized tests failing for AlgClosure{fqPolyRepField} #2691

lgoettgens opened this issue Aug 17, 2023 · 15 comments · Fixed by Nemocas/Nemo.jl#1579
Labels
bug Something isn't working topic: rings

Comments

@lgoettgens
Copy link
Member

Starting with #2684, I noticed some seemingly random fails on the master CI with different julia versions.
All are pretty lengthy, but contain something like the following multiple times:

Basic functions: Error During Test at /home/runner/.julia/packages/AbstractAlgebra/lDlYU/test/Rings-conformance-tests.jl:98
  Test threw exception
  Expression: equality(a - c, a + -c)
  MethodError: objects of type Nothing are not callable
  Stacktrace:
   [1] (::fqPolyRepField)(b::fqPolyRepFieldElem)
     @ Nemo ~/.julia/packages/Nemo/Tj33G/src/flint/fq_nmod.jl:660
   [2] op(f::typeof(-), a::AlgClosureElem{fqPolyRepField}, b::AlgClosureElem{fqPolyRepField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:117
   [3] -(a::AlgClosureElem{fqPolyRepField}, b::AlgClosureElem{fqPolyRepField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:126
   [4] macro expansion
     @ ~/.julia/packages/AbstractAlgebra/lDlYU/test/Rings-conformance-tests.jl:98 [inlined]
   [5] macro expansion
     @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [6] macro expansion
     @ ~/.julia/packages/AbstractAlgebra/lDlYU/test/Rings-conformance-tests.jl:70 [inlined]
   [7] macro expansion
     @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [8] test_NCRing_interface(R::AlgClosure{fqPolyRepField}; reps::Int64)
     @ Main ~/.julia/packages/AbstractAlgebra/lDlYU/test/Rings-conformance-tests.jl:31

Full logs for 1.6 (https://github.com/oscar-system/Oscar.jl/actions/runs/5871596739/job/15921330205#step:6:1010) and nightly (https://github.com/oscar-system/Oscar.jl/actions/runs/5869443753/job/15914431074?pr=2644#step:6:1010).

cc @ThomasBreuer

@lgoettgens lgoettgens added bug Something isn't working topic: rings labels Aug 17, 2023
@ThomasBreuer
Copy link
Member

ThomasBreuer commented Aug 17, 2023

Funny.

Perhaps the simplest situation where a failure is reported is @test K(one(F2)) == K(one(F3)), because it happens outside the conformance test setup, and does not involve the creation of random elements:

Comparison for Finite field of degree 1 over GF(3): Error During Test at /home/runner/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:133
  Test threw exception
  Expression: K(one(F2)) == K(one(F3))
  MethodError: objects of type Nothing are not callable
  Stacktrace:
   [1] (::fqPolyRepField)(b::fqPolyRepFieldElem)
     @ Nemo ~/.julia/packages/Nemo/Tj33G/src/flint/fq_nmod.jl:660
   [2] op(f::typeof(==), a::AlgClosureElem{fqPolyRepField}, b::AlgClosureElem{fqPolyRepField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:117
   [3] ==(a::AlgClosureElem{fqPolyRepField}, b::AlgClosureElem{fqPolyRepField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:131
   [4] eval_test(evaluated::Expr, quoted::Expr, source::LineNumberNode, negate::Bool)
     @ Test /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:277
   [5] macro expansion
     @ ~/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:133 [inlined]
   [6] macro expansion
     @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1226 [inlined]
   [7] macro expansion
     @ ~/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:125 [inlined]
   [8] macro expansion
     @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [9] top-level scope
     @ ~/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:8

Up to now, I cannot reproduce the failures locally.
And I do not see where in the code the problem is; the test mentioned above should fail either always or never.

@fingolfin
Copy link
Member

The line where the error happens is this:

function (a::fqPolyRepField)(b::fqPolyRepFieldElem)
    k = parent(b)
    da = degree(a)
    dk = degree(k)
    if k == a
        return b
    elseif dk < da
        da % dk != 0 && error("Coercion impossible")
        f = embed(k, a)
        return f(b)  # <--- error is here
    else
        dk % da != 0 && error("Coercion impossible")
        f = preimage_map(a, k)
        return f(b)
    end
end

So presumably embed returned nothing?

@lgoettgens
Copy link
Member Author

Following @code_warntype, the place where nothing can be returned in embed is https://github.com/Nemocas/Nemo.jl/blob/407b0e0b5d3dc0d7ae9a7a1eb99b14b688e0a1a8/src/embedding/embedding.jl#L428
And looking at that function, there are cases where is_embedded returns nothing.

@ThomasBreuer
Copy link
Member

ThomasBreuer commented Aug 17, 2023

My interpretation of the embed code in question is that the result of the intersections call is false only if the required embedding is known and hence is_embedded will return something.
Since the failure shows up only randomly, could the problem perhaps be that some cached values get lost?
Perhaps @thofma has an idea?

@thofma
Copy link
Collaborator

thofma commented Aug 22, 2023

I am (still) looking at this. I could finally manage to reproduce it locally.

@thofma
Copy link
Collaborator

thofma commented Aug 24, 2023

Here is how to reproduce it:

using Oscar, Test;
K = algebraic_closure(GF(3, 1));
data = [(1, [0]), (6, [0, 1, 2, 2, 1, 2]), (1, [0]), (4, [1, 0, 2, 0]), (8, [1, 0, 2, 1, 1, 2, 0, 0]), (6, [2, 0, 1, 2, 2, 1]), (8, [1, 1, 2, 2, 1, 2, 2, 0]), (2, [1, 2]), (1, [1]), (7, [0, 1, 2, 0, 0, 0, 2]), (8, [2, 1, 1, 2, 1, 0, 1, 0]), (5, [0, 1, 1, 1, 1]), (4, [2, 1, 0, 1]), (2, [2, 2]), (3, [1, 1, 0]), (1, [1]), (6, [1, 2, 1, 0, 2, 0]), (7, [1, 1, 1, 2, 2, 0, 2]), (3, [2, 2, 1]), (5, [0, 0, 0, 2, 1]), (2, [0, 0]), (1, [0]), (1, [1]), (3, [1, 2, 2]), (2, [1, 2]), (4, [0, 2, 2, 2]), (4, [0, 1, 2, 2]), (6, [2, 2, 1, 1, 0, 0]), (3, [0, 2, 2]), (4, [0, 0, 1, 0]), (4, [1, 0, 0, 2]), (8, [1, 0, 2, 2, 1, 2, 2, 1]), (6, [2, 2, 2, 2, 1, 0]), (4, [1, 1, 2, 1]), (2, [1, 0]), (2, [1, 0]), (5, [0, 0, 0, 0, 0]), (8, [2, 1, 1, 2, 2, 1, 0, 0]), (7, [1, 1, 2, 1, 2, 2, 1]), (6, [1, 2, 1, 1, 1, 1]), (4, [1, 2, 2, 1]), (1, [2]), (3, [1, 0, 0]), (3, [1, 1, 2]), (7, [2, 2, 2, 2, 0, 2, 0]), (2, [2, 2]), (2, [2, 1]), (7, [2, 1, 1, 0, 2, 1, 0]), (5, [2, 1, 0, 0, 1]), (8, [1, 1, 2, 2, 1, 1, 0, 0]), (1, [0]), (6, [0, 1, 2, 2, 1, 2]), (1, [0]), (4, [1, 0, 2, 0]), (8, [1, 0, 2, 1, 1, 2, 0, 0]), (6, [2, 0, 1, 2, 2, 1]), (8, [1, 1, 2, 2, 1, 2, 2, 0]), (2, [1, 2]), (1, [1]), (7, [0, 1, 2, 0, 0, 0, 2]), (8, [2, 1, 1, 2, 1, 0, 1, 0]), (5, [0, 1, 1, 1, 1]), (4, [2, 1, 0, 1]), (2, [2, 2]), (3, [1, 1, 0]), (1, [1]), (6, [1, 2, 1, 0, 2, 0]), (7, [1, 1, 1, 2, 2, 0, 2]), (3, [2, 2, 1]), (5, [0, 0, 0, 2, 1]), (2, [0, 0]), (1, [0]), (1, [1]), (3, [1, 2, 2]), (2, [1, 2]), (4, [0, 2, 2, 2]), (4, [0, 1, 2, 2]), (6, [2, 2, 1, 1, 0, 0]), (3, [0, 2, 2]), (4, [0, 0, 1, 0]), (4, [1, 0, 0, 2]), (8, [1, 0, 2, 2, 1, 2, 2, 1]), (6, [2, 2, 2, 2, 1, 0]), (4, [1, 1, 2, 1]), (2, [1, 0]), (2, [1, 0]), (5, [0, 0, 0, 0, 0]), (8, [2, 1, 1, 2, 2, 1, 0, 0]), (7, [1, 1, 2, 1, 2, 2, 1]), (6, [1, 2, 1, 1, 1, 1]), (4, [1, 2, 2, 1]), (1, [2]), (3, [1, 0, 0]), (3, [1, 1, 2]), (7, [2, 2, 2, 2, 0, 2, 0]), (2, [2, 2]), (2, [2, 1]), (7, [2, 1, 1, 0, 2, 1, 0]), (5, [2, 1, 0, 0, 1]), (8, [1, 1, 2, 2, 1, 1, 0, 0]), (1, [0]), (6, [0, 1, 2, 2, 1, 2]), (1, [0]), (4, [1, 0, 2, 0]), (8, [1, 0, 2, 1, 1, 2, 0, 0]), (6, [2, 0, 1, 2, 2, 1]), (8, [1, 1, 2, 2, 1, 2, 2, 0]), (2, [1, 2]), (1, [1]), (7, [0, 1, 2, 0, 0, 0, 2]), (8, [2, 1, 1, 2, 1, 0, 1, 0]), (5, [0, 1, 1, 1, 1]), (4, [2, 1, 0, 1]), (2, [2, 2]), (3, [1, 1, 0]), (1, [1]), (6, [1, 2, 1, 0, 2, 0]), (7, [1, 1, 1, 2, 2, 0, 2]), (3, [2, 2, 1]), (5, [0, 0, 0, 2, 1]), (2, [0, 0]), (1, [0]), (1, [1]), (3, [1, 2, 2]), (2, [1, 2]), (4, [0, 2, 2, 2]), (4, [0, 1, 2, 2]), (6, [2, 2, 1, 1, 0, 0]), (3, [0, 2, 2]), (4, [0, 0, 1, 0]), (4, [1, 0, 0, 2]), (8, [1, 0, 2, 2, 1, 2, 2, 1]), (6, [2, 2, 2, 2, 1, 0]), (4, [1, 1, 2, 1]), (2, [1, 0]), (2, [1, 0]), (5, [0, 0, 0, 0, 0]), (8, [2, 1, 1, 2, 2, 1, 0, 0]), (7, [1, 1, 2, 1, 2, 2, 1]), (6, [1, 2, 1, 1, 1, 1]), (4, [1, 2, 2, 1]), (1, [2]), (3, [1, 0, 0]), (3, [1, 1, 2]), (7, [2, 2, 2, 2, 0, 2, 0]), (2, [2, 2]), (2, [2, 1]), (7, [2, 1, 1, 0, 2, 1, 0]), (5, [2, 1, 0, 0, 1]), (8, [1, 1, 2, 2, 1, 1, 0, 0]), (7, [0, 1, 2, 2, 1, 1, 0]), (7, [0, 0, 2, 2, 0, 1, 1]), (5, [0, 0, 1, 1, 2]), (2, [0, 2]), (3, [1, 1, 1]), (1, [0]), (6, [2, 0, 1, 0, 2, 0]), (7, [2, 0, 1, 1, 2, 2, 1]), (2, [1, 2]), (1, [0]), (1, [2]), (6, [2, 1, 0, 2, 2, 2]), (3, [0, 0, 2]), (3, [1, 0, 0]), (5, [1, 2, 0, 0, 0]), (7, [0, 0, 1, 2, 0, 1, 0]), (6, [0, 2, 0, 0, 2, 0]), (2, [0, 0]), (2, [2, 1]), (6, [0, 2, 0, 0, 2, 1]), (6, [0, 1, 1, 2, 0, 0]), (6, [0, 0, 0, 2, 1, 1]), (5, [2, 2, 2, 2, 2]), (4, [2, 1, 2, 2]), (2, [0, 0]), (2, [1, 2]), (1, [0]), (8, [1, 2, 0, 0, 2, 2, 2, 0]), (6, [2, 2, 2, 2, 0, 1]), (7, [2, 2, 1, 2, 1, 2, 0]), (8, [2, 1, 2, 2, 2, 2, 1, 1]), (5, [1, 2, 1, 2, 2]), (2, [0, 2]), (5, [1, 1, 1, 0, 2]), (1, [1]), (7, [0, 2, 0, 1, 2, 2, 1]), (3, [0, 1, 2]), (6, [0, 2, 0, 0, 0, 0]), (3, [0, 0, 2]), (3, [0, 2, 2]), (6, [0, 0, 2, 1, 0, 1]), (7, [2, 2, 2, 2, 0, 0, 1]), (7, [2, 2, 2, 1, 1, 2, 2]), (3, [2, 0, 1]), (5, [0, 2, 2, 2, 2]), (4, [0, 1, 2, 2]), (1, [0]), (1, [2]), (1, [1]), (1, [1]), (1, [0]), (7, [1, 2, 1, 2, 2, 1, 1]), (4, [1, 2, 1, 2]), (1, [1]), (5, [0, 2, 1, 0, 2]), (7, [1, 2, 0, 0, 0, 1, 1]), (8, [0, 1, 1, 1, 1, 1, 0, 2]), (7, [0, 1, 0, 0, 1, 2, 2]), (1, [0]), (4, [0, 1, 2, 2]), (8, [2, 1, 2, 0, 1, 1, 1, 2]), (6, [0, 2, 2, 0, 2, 0]), (5, [1, 2, 1, 0, 1]), (1, [1]), (3, [0, 2, 2]), (2, [1, 2]), (8, [2, 0, 0, 2, 2, 2, 0, 1]), (4, [2, 1, 0, 0]), (4, [2, 2, 2, 0]), (3, [1, 1, 0]), (6, [2, 2, 2, 1, 1, 0]), (8, [1, 2, 0, 2, 2, 0, 1, 1]), (5, [0, 2, 2, 2, 2]), (7, [1, 0, 2, 2, 2, 1, 0]), (2, [2, 0]), (1, [1]), (3, [0, 2, 2]), (1, [1]), (1, [2]), (2, [2, 0]), (8, [1, 1, 0, 1, 0, 2, 2, 1]), (4, [1, 2, 0, 2]), (3, [0, 1, 2]), (4, [0, 1, 2, 0]), (1, [2]), (8, [0, 0, 1, 0, 0, 1, 1, 0]), (1, [1]), (7, [1, 2, 2, 1, 0, 0, 1]), (8, [2, 2, 0, 1, 1, 0, 1, 2]), (8, [0, 0, 2, 2, 2, 2, 2, 1]), (3, [2, 0, 2]), (4, [1, 1, 0, 1]), (8, [1, 0, 1, 0, 2, 1, 1, 1]), (2, [2, 2]), (5, [1, 1, 2, 2, 1]), (6, [1, 2, 0, 1, 2, 2]), (5, [1, 0, 0, 2, 2]), (6, [0, 0, 0, 2, 0, 2]), (2, [0, 2]), (8, [2, 0, 2, 1, 2, 1, 2, 2]), (3, [1, 2, 0]), (8, [1, 0, 0, 1, 2, 0, 0, 0]), (5, [2, 2, 0, 1, 1]), (5, [0, 0, 2, 1, 1]), (4, [0, 0, 0, 0]), (8, [1, 0, 1, 2, 2, 1, 2, 2]), (7, [2, 1, 0, 1, 1, 0, 0]), (6, [1, 2, 0, 1, 0, 0]), (1, [0]), (5, [0, 1, 1, 1, 2]), (4, [1, 2, 0, 0]), (7, [2, 2, 0, 1, 1, 2, 0]), (7, [2, 2, 0, 0, 2, 2, 1]), (5, [2, 1, 0, 0, 1]), (2, [1, 0]), (3, [0, 2, 1]), (2, [2, 0]), (6, [0, 2, 0, 1, 2, 1]), (8, [0, 0, 2, 0, 0, 0, 2, 0]), (5, [0, 1, 0, 2, 0]), (3, [2, 0, 1]), (2, [2, 0]), (4, [0, 2, 2, 2]), (7, [0, 0, 1, 2, 1, 0, 1]), (6, [1, 1, 2, 0, 1, 1]), (5, [1, 2, 1, 2, 1]), (8, [0, 2, 0, 0, 2, 2, 0, 2]), (3, [0, 0, 0]), (7, [1, 2, 1, 2, 1, 2, 2]), (7, [1, 0, 0, 0, 0, 1, 1]), (5, [1, 2, 2, 0, 1]), (4, [1, 1, 0, 0]), (1, [1]), (2, [0, 1]), (2, [1, 1]), (2, [0, 0]), (1, [2]), (5, [1, 0, 2, 1, 0]), (2, [2, 2]), (6, [1, 2, 1, 2, 1, 1]), (4, [1, 0, 1, 2]), (8, [2, 2, 1, 2, 1, 2, 0, 0]), (7, [2, 0, 0, 0, 0, 1, 2]), (6, [1, 0, 0, 0, 1, 0]), (4, [0, 0, 2, 0]), (6, [0, 1, 1, 0, 2, 0]), (5, [0, 0, 2, 0, 1]), (8, [1, 1, 2, 1, 2, 0, 0, 1]), (8, [1, 1, 0, 1, 1, 1, 1, 2]), (6, [2, 1, 0, 0, 0, 1]), (1, [0]), (6, [0, 1, 2, 2, 1, 2]), (1, [0]), (4, [1, 0, 2, 0]), (8, [1, 0, 2, 1, 1, 2, 0, 0]), (6, [2, 0, 1, 2, 2, 1]), (8, [1, 1, 2, 2, 1, 2, 2, 0]), (2, [1, 2]), (1, [1]), (7, [0, 1, 2, 0, 0, 0, 2]), (8, [2, 1, 1, 2, 1, 0, 1, 0]), (5, [0, 1, 1, 1, 1]), (4, [2, 1, 0, 1]), (2, [2, 2]), (3, [1, 1, 0]), (1, [1]), (6, [1, 2, 1, 0, 2, 0]), (7, [1, 1, 1, 2, 2, 0, 2]), (3, [2, 2, 1]), (5, [0, 0, 0, 2, 1]), (2, [0, 0]), (1, [0]), (1, [1]), (3, [1, 2, 2]), (2, [1, 2]), (4, [0, 2, 2, 2]), (4, [0, 1, 2, 2]), (6, [2, 2, 1, 1, 0, 0]), (3, [0, 2, 2]), (4, [0, 0, 1, 0]), (4, [1, 0, 0, 2]), (8, [1, 0, 2, 2, 1, 2, 2, 1]), (6, [2, 2, 2, 2, 1, 0]), (4, [1, 1, 2, 1]), (2, [1, 0]), (2, [1, 0]), (5, [0, 0, 0, 0, 0]), (8, [2, 1, 1, 2, 2, 1, 0, 0]), (7, [1, 1, 2, 1, 2, 2, 1]), (6, [1, 2, 1, 1, 1, 1]), (4, [1, 2, 2, 1]), (1, [2]), (3, [1, 0, 0]), (3, [1, 1, 2]), (7, [2, 2, 2, 2, 0, 2, 0]), (2, [2, 2]), (2, [2, 1]), (7, [2, 1, 1, 0, 2, 1, 0]), (5, [2, 1, 0, 0, 1]), (8, [1, 1, 2, 2, 1, 1, 0, 0]), (7, [0, 1, 2, 2, 1, 1, 0]), (7, [0, 0, 2, 2, 0, 1, 1]), (5, [0, 0, 1, 1, 2]), (2, [0, 2]), (3, [1, 1, 1]), (1, [0]), (6, [2, 0, 1, 0, 2, 0]), (7, [2, 0, 1, 1, 2, 2, 1]), (2, [1, 2]), (1, [0]), (1, [2]), (6, [2, 1, 0, 2, 2, 2]), (3, [0, 0, 2]), (3, [1, 0, 0]), (5, [1, 2, 0, 0, 0]), (7, [0, 0, 1, 2, 0, 1, 0]), (6, [0, 2, 0, 0, 2, 0]), (2, [0, 0]), (2, [2, 1]), (6, [0, 2, 0, 0, 2, 1]), (6, [0, 1, 1, 2, 0, 0]), (6, [0, 0, 0, 2, 1, 1]), (5, [2, 2, 2, 2, 2]), (4, [2, 1, 2, 2]), (2, [0, 0]), (2, [1, 2]), (1, [0]), (8, [1, 2, 0, 0, 2, 2, 2, 0]), (6, [2, 2, 2, 2, 0, 1]), (7, [2, 2, 1, 2, 1, 2, 0]), (8, [2, 1, 2, 2, 2, 2, 1, 1]), (5, [1, 2, 1, 2, 2]), (2, [0, 2]), (5, [1, 1, 1, 0, 2]), (1, [1]), (7, [0, 2, 0, 1, 2, 2, 1]), (3, [0, 1, 2]), (6, [0, 2, 0, 0, 0, 0]), (3, [0, 0, 2]), (3, [0, 2, 2]), (6, [0, 0, 2, 1, 0, 1]), (7, [2, 2, 2, 2, 0, 0, 1]), (7, [2, 2, 2, 1, 1, 2, 2]), (3, [2, 0, 1]), (5, [0, 2, 2, 2, 2]), (4, [0, 1, 2, 2]), (1, [0]), (1, [2]), (1, [1]), (1, [1]), (1, [0]), (7, [1, 2, 1, 2, 2, 1, 1]), (4, [1, 2, 1, 2]), (1, [1]), (5, [0, 2, 1, 0, 2]), (7, [1, 2, 0, 0, 0, 1, 1]), (8, [0, 1, 1, 1, 1, 1, 0, 2]), (7, [0, 1, 0, 0, 1, 2, 2]), (1, [0]), (4, [0, 1, 2, 2]), (8, [2, 1, 2, 0, 1, 1, 1, 2]), (6, [0, 2, 2, 0, 2, 0]), (5, [1, 2, 1, 0, 1]), (1, [1]), (3, [0, 2, 2]), (2, [1, 2]), (8, [2, 0, 0, 2, 2, 2, 0, 1]), (4, [2, 1, 0, 0]), (4, [2, 2, 2, 0]), (3, [1, 1, 0]), (6, [2, 2, 2, 1, 1, 0]), (8, [1, 2, 0, 2, 2, 0, 1, 1]), (5, [0, 2, 2, 2, 2]), (7, [1, 0, 2, 2, 2, 1, 0]), (2, [2, 0]), (1, [1]), (3, [0, 2, 2]), (1, [1]), (1, [2]), (2, [2, 0]), (8, [1, 1, 0, 1, 0, 2, 2, 1]), (4, [1, 2, 0, 2]), (3, [0, 1, 2]), (4, [0, 1, 2, 0]), (1, [2]), (8, [0, 0, 1, 0, 0, 1, 1, 0]), (1, [1]), (7, [1, 2, 2, 1, 0, 0, 1]), (8, [2, 2, 0, 1, 1, 0, 1, 2]), (8, [0, 0, 2, 2, 2, 2, 2, 1]), (3, [2, 0, 2]), (4, [1, 1, 0, 1]), (8, [1, 0, 1, 0, 2, 1, 1, 1]), (2, [2, 2]), (5, [1, 1, 2, 2, 1]), (6, [1, 2, 0, 1, 2, 2]), (5, [1, 0, 0, 2, 2]), (6, [0, 0, 0, 2, 0, 2]), (2, [0, 2]), (8, [2, 0, 2, 1, 2, 1, 2, 2]), (1, [0]), (6, [0, 1, 2, 2, 1, 2]), (1, [0]), (4, [1, 0, 2, 0]), (8, [1, 0, 2, 1, 1, 2, 0, 0]), (6, [2, 0, 1, 2, 2, 1]), (8, [1, 1, 2, 2, 1, 2, 2, 0]), (2, [1, 2]), (1, [1]), (7, [0, 1, 2, 0, 0, 0, 2]), (8, [2, 1, 1, 2, 1, 0, 1, 0]), (5, [0, 1, 1, 1, 1]), (4, [2, 1, 0, 1]), (2, [2, 2]), (3, [1, 1, 0]), (1, [1]), (6, [1, 2, 1, 0, 2, 0]), (7, [1, 1, 1, 2, 2, 0, 2]), (3, [2, 2, 1]), (5, [0, 0, 0, 2, 1]), (2, [0, 0]), (1, [0]), (1, [1]), (3, [1, 2, 2]), (2, [1, 2]), (4, [0, 2, 2, 2]), (4, [0, 1, 2, 2]), (6, [2, 2, 1, 1, 0, 0]), (3, [0, 2, 2]), (4, [0, 0, 1, 0]), (4, [1, 0, 0, 2]), (8, [1, 0, 2, 2, 1, 2, 2, 1]), (6, [2, 2, 2, 2, 1, 0]), (4, [1, 1, 2, 1]), (2, [1, 0]), (2, [1, 0]), (5, [0, 0, 0, 0, 0]), (8, [2, 1, 1, 2, 2, 1, 0, 0]), (7, [1, 1, 2, 1, 2, 2, 1]), (6, [1, 2, 1, 1, 1, 1]), (4, [1, 2, 2, 1]), (1, [2]), (3, [1, 0, 0]), (3, [1, 1, 2]), (7, [2, 2, 2, 2, 0, 2, 0]), (2, [2, 2]), (2, [2, 1]), (7, [2, 1, 1, 0, 2, 1, 0]), (5, [2, 1, 0, 0, 1]), (8, [1, 1, 2, 2, 1, 1, 0, 0]), (7, [0, 1, 2, 2, 1, 1, 0]), (7, [0, 0, 2, 2, 0, 1, 1]), (5, [0, 0, 1, 1, 2]), (2, [0, 2]), (3, [1, 1, 1]), (1, [0]), (6, [2, 0, 1, 0, 2, 0]), (7, [2, 0, 1, 1, 2, 2, 1]), (2, [1, 2]), (1, [0]), (1, [2]), (6, [2, 1, 0, 2, 2, 2]), (3, [0, 0, 2]), (3, [1, 0, 0]), (5, [1, 2, 0, 0, 0]), (7, [0, 0, 1, 2, 0, 1, 0]), (6, [0, 2, 0, 0, 2, 0]), (2, [0, 0]), (2, [2, 1]), (6, [0, 2, 0, 0, 2, 1]), (6, [0, 1, 1, 2, 0, 0]), (6, [0, 0, 0, 2, 1, 1]), (5, [2, 2, 2, 2, 2]), (4, [2, 1, 2, 2]), (2, [0, 0]), (2, [1, 2]), (1, [0]), (8, [1, 2, 0, 0, 2, 2, 2, 0]), (6, [2, 2, 2, 2, 0, 1]), (7, [2, 2, 1, 2, 1, 2, 0]), (8, [2, 1, 2, 2, 2, 2, 1, 1]), (5, [1, 2, 1, 2, 2]), (2, [0, 2]), (5, [1, 1, 1, 0, 2]), (1, [1]), (7, [0, 2, 0, 1, 2, 2, 1]), (3, [0, 1, 2]), (6, [0, 2, 0, 0, 0, 0]), (3, [0, 0, 2]), (3, [0, 2, 2]), (6, [0, 0, 2, 1, 0, 1]), (7, [2, 2, 2, 2, 0, 0, 1]), (7, [2, 2, 2, 1, 1, 2, 2]), (3, [2, 0, 1]), (5, [0, 2, 2, 2, 2]), (4, [0, 1, 2, 2]), (1, [0]), (1, [2]), (1, [1]), (1, [1]), (1, [0]), (6, [0, 1, 2, 2, 1, 2]), (1, [0]), (4, [1, 0, 2, 0]), (8, [1, 0, 2, 1, 1, 2, 0, 0]), (6, [2, 0, 1, 2, 2, 1]), (8, [1, 1, 2, 2, 1, 2, 2, 0]), (2, [1, 2]), (1, [1]), (7, [0, 1, 2, 0, 0, 0, 2]), (8, [2, 1, 1, 2, 1, 0, 1, 0]), (5, [0, 1, 1, 1, 1]), (4, [2, 1, 0, 1]), (2, [2, 2]), (3, [1, 1, 0]), (1, [1]), (6, [1, 2, 1, 0, 2, 0]), (7, [1, 1, 1, 2, 2, 0, 2]), (3, [2, 2, 1]), (5, [0, 0, 0, 2, 1]), (2, [0, 0]), (1, [0]), (1, [1]), (3, [1, 2, 2]), (2, [1, 2]), (4, [0, 2, 2, 2]), (4, [0, 1, 2, 2]), (6, [2, 2, 1, 1, 0, 0]), (3, [0, 2, 2]), (4, [0, 0, 1, 0]), (4, [1, 0, 0, 2]), (8, [1, 0, 2, 2, 1, 2, 2, 1]), (6, [2, 2, 2, 2, 1, 0]), (4, [1, 1, 2, 1]), (2, [1, 0]), (2, [1, 0]), (5, [0, 0, 0, 0, 0]), (8, [2, 1, 1, 2, 2, 1, 0, 0]), (7, [1, 1, 2, 1, 2, 2, 1]), (6, [1, 2, 1, 1, 1, 1]), (4, [1, 2, 2, 1]), (1, [2]), (3, [1, 0, 0]), (3, [1, 1, 2]), (7, [2, 2, 2, 2, 0, 2, 0]), (2, [2, 2]), (2, [2, 1]), (7, [2, 1, 1, 0, 2, 1, 0]), (5, [2, 1, 0, 0, 1]), (8, [1, 1, 2, 2, 1, 1, 0, 0])];
global i = 1;
function test_elem(K::AlgClosure{T}) where T <: FinField
  global i;
  j = i;
  i = i + 1;
  K(ext_of_degree(K, data[j][1])(data[j][2]));
end
include(joinpath(pathof(AbstractAlgebra), "..", "..", "test", "Rings-conformance-tests.jl"));
test_Field_interface(K); # this will error
elts = [ K(ext_of_degree(K, d[1])(d[2])) for d in data];
a = elts[8]; b = elts[12]; c = elts[2];
aa = a + b; # aa + c will error
ad = Oscar.data(aa); bd = Oscar.data(c);
l = lcm(degree(parent(ad)), degree(parent(bd)))
k = ext_of_degree(parent(a), l)
embed(parent(ad), k) # this returns nothing, which is bad

It is unrelated to caching and looks more like a bug in the embedding code (the theory of which is "described" here: https://dl.acm.org/doi/abs/10.1145/3282678.3282682). Because of its recursive nature, it is a bit tedious to follow. Feel free to look at it. Otherwise I will discuss it with @fieker once he is back from holiday.

@ThomasBreuer
Copy link
Member

Thanks @thofma, this looks very interesting.

@thofma
Copy link
Collaborator

thofma commented Aug 25, 2023

Here are some bread crumps, so that I don't forget about it:

embed(parent(ad), k)

will call

intersections(parent(ad), k)

(https://github.com/Nemocas/Nemo.jl/blob/master/src/embedding/embedding.jl#L301)
Since k has a subfield of degree 10 (distinct from parent(ad)), this will hit
https://github.com/Nemocas/Nemo.jl/blob/fd27c979490a21b16c119fee4e6e4d85ad31ea4f/src/embedding/embedding.jl#L325-L327
Hence we call embed(parent(ad), kk) where kk = k.subfields[10][1]. By "transitivity", this should also compute an embedding embed(parent(ad), k), but it does not. The call embed(parent(ad), kk) will hit the branch
https://github.com/Nemocas/Nemo.jl/blob/fd27c979490a21b16c119fee4e6e4d85ad31ea4f/src/embedding/embedding.jl#L395-L400
which just returns a map parent(ad) -> kk. But in this branch, no transitive closure is computed. I don't know whether the problem is

  1. that this branch does not compute the transitive closure, or
  2. that the lattice is already in an inconsistent state.
    (I tried fixing 1., but ran in an infinite recursion.)

@fingolfin
Copy link
Member

OK, part of the issue is indeed this function (following the hint by @lgoettgens) in this code:

function is_embedded(k::T, K::T) where T <: FinField


    d = degree(K)
    ov = overfields(k)


    # We look for an embedding that has k as domain and K as codomain


    if haskey(ov, d)
        for f in ov[d]
            if domain(f) == k && codomain(f) == K
                return f
            end
        end
    end
end

Clearly this function returns a cached value if available -- and otherwise nothing (funnily it never returns a boolean, despite being called is_embedded ;-) -- I guess we should rename it).

So it seems the return value of intersections, which is needmore, is not reliable.

Perhaps it suffices to replace the check for needmore by instead first calling is_embedded; if it gives something, return that, if not, set needmore = true.

@fingolfin
Copy link
Member

This should be fixed by PR #2739 ; however, there are more issues hidden in the subfield lattice code, which need to be addressed. We asked @mjrodgers to look into some of this.

@HereAround
Copy link
Member

I am still seeing this sort of failure in run https://github.com/oscar-system/Oscar.jl/actions/runs/6023945049/job/16341680795?pr=2741. The PR has been rebased to the latest master in the morning and ran around noon today. Please have a brief look.

@HereAround HereAround reopened this Aug 30, 2023
@benlorenz
Copy link
Member

This error looks similar, from today (#2764):

Arithmetic for Finite field of degree 1 over GF(3): Error During Test at /Users/runner/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:89
  Test threw exception
  Expression: a * (b + c) == a * b + a * c
  MethodError: objects of type Nothing are not callable
  Stacktrace:
   [1] (::FqField)(b::FqFieldElem)
     @ Nemo ~/.julia/packages/Nemo/Tj33G/src/flint/fq_default_extended.jl:703
   [2] op(f::typeof(*), a::AlgClosureElem{FqField}, b::AlgClosureElem{FqField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:129
   [3] *(a::AlgClosureElem{FqField}, b::AlgClosureElem{FqField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:140
   [4] macro expansion
     @ ~/hostedtoolcache/julia/1.9.3/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:478 [inlined]
   [5] macro expansion
     @ ~/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:89 [inlined]
   [6] macro expansion
     @ ~/hostedtoolcache/julia/1.9.3/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:1586 [inlined]
   [7] macro expansion
     @ ~/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:77 [inlined]
   [8] macro expansion
     @ ~/hostedtoolcache/julia/1.9.3/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:1498 [inlined]
   [9] top-level scope
     @ ~/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:8

@fingolfin
Copy link
Member

I haven't seen this bug recently, so maybe it is fixed (or at least this aspect of it) after all?

@benlorenz
Copy link
Member

benlorenz commented Sep 20, 2023

Not really, it happened again here, 2 hours ago on master:

Basic functions: Error During Test at /Users/runner/.julia/packages/AbstractAlgebra/Ry0na/test/Rings-conformance-tests.jl:96
  Test threw exception
  Expression: equality((a + b) + c, a + (b + c))
  MethodError: objects of type Nothing are not callable
  Stacktrace:
   [1] (::fqPolyRepField)(b::fqPolyRepFieldElem)
     @ Nemo ~/.julia/packages/Nemo/yGn7K/src/flint/fq_nmod.jl:660
   [2] op(f::typeof(+), a::AlgClosureElem{fqPolyRepField}, b::AlgClosureElem{fqPolyRepField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:129
   [3] +(a::AlgClosureElem{fqPolyRepField}, b::AlgClosureElem{fqPolyRepField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:132
   [4] macro expansion
     @ ~/hostedtoolcache/julia/1.9.3/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:478 [inlined]
   [5] macro expansion
     @ ~/.julia/packages/AbstractAlgebra/Ry0na/test/Rings-conformance-tests.jl:96 [inlined]
   [6] macro expansion
     @ ~/hostedtoolcache/julia/1.9.3/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:1498 [inlined]
   [7] macro expansion
     @ ~/.julia/packages/AbstractAlgebra/Ry0na/test/Rings-conformance-tests.jl:70 [inlined]
   [8] macro expansion
     @ ~/hostedtoolcache/julia/1.9.3/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:1498 [inlined]
   [9] test_NCRing_interface(R::AlgClosure{fqPolyRepField}; reps::Int64)
     @ Main ~/.julia/packages/AbstractAlgebra/Ry0na/test/Rings-conformance-tests.jl:31

and here as well, 10 hours ago:

Arithmetic for Finite field of degree 1 over GF(3): Error During Test at /Users/runner/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:89
  Test threw exception
  Expression: a * (b + c) == a * b + a * c
  MethodError: objects of type Nothing are not callable
  Stacktrace:
   [1] (::FqField)(b::FqFieldElem)
     @ Nemo ~/.julia/packages/Nemo/yGn7K/src/flint/fq_default_extended.jl:705
   [2] op(f::typeof(+), a::AlgClosureElem{FqField}, b::AlgClosureElem{FqField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:129
   [3] +(a::AlgClosureElem{FqField}, b::AlgClosureElem{FqField})
     @ Oscar.AlgClosureFp ~/work/Oscar.jl/Oscar.jl/src/Rings/AlgClosureFp.jl:132
   [4] macro expansion
     @ ~/hostedtoolcache/julia/1.9.3/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:478 [inlined]
   [5] macro expansion
     @ ~/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:89 [inlined]
   [6] macro expansion
     @ ~/hostedtoolcache/julia/1.9.3/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:1586 [inlined]
   [7] macro expansion
     @ ~/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:77 [inlined]
   [8] macro expansion
     @ ~/hostedtoolcache/julia/1.9.3/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:1498 [inlined]
   [9] top-level scope
     @ ~/work/Oscar.jl/Oscar.jl/test/Rings/AlgClosureFp.jl:8

One is for FqField and the other one for fqPolyRepField.

@mjrodgers
Copy link
Collaborator

Just an update on this, I have been taking a look on it and reading about how this lattice of embedded subfields is handled in Magma. As for these randomized tests failing, it is something I haven't been able to recreate at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working topic: rings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants