Open HereAround opened 1 year ago
There is some relevant text on the caches in the AA documentation, as part of the ring interface. We should check if this text still reflects what we want, and then copy it (after editing) into the OSCAR dev docs.
Also we need to think about allowing optional specification of parents in more functions, e.g. hilbert_series
; there is an open PR #2084 by @HechtiDerLachs on this, which we need to get finished and merged.
The overall situation is still rather bad, it wouldn't hurt to evangelize this again, and task some people to work on it.
Running
git grep -n '\bpolynomial_ring(' src | fgrep -v 'julia> ' | fgrep -v 'src/InvariantTheory' | egrep -v 'cached\s*=\s*false'
to find examples in Oscar.jl where code creates cached polynomial rings, one finds (excluding some obvious false hits):
newring, _ = polynomial_ring(K, symbols(R))
S, t = polynomial_ring(W, ["t$i" for i in 1:r])
KL, z = polynomial_ring(k, new_symb)
RS, z = polynomial_ring(k, new_symb)
R, _ = polynomial_ring(kk, [variable_name * "$i" for i in 1:n])
R, _ = polynomial_ring(kk, var_symbols)
R, _ = polynomial_ring(kk, [variable_name * "$i" for i in 1:n])
R, _ = polynomial_ring(kk, var_symbols)
P, _ = polynomial_ring(kk, symbols(R))
R,x = polynomial_ring(QQ,"x")
ring, vars = polynomial_ring(QQ, var_names)
R, x = polynomial_ring(F, :"x"=>MC)
R, x = polynomial_ring(F, :"x"=>MR)
R, (x, y) = polynomial_ring(ZZ, ["x", "y"])
R, q = polynomial_ring(ZZ, 'q')
R, q = polynomial_ring(ZZ, 'q')
R, = polynomial_ring(QQ, "x")
R1 = polynomial_ring(base_ring(f), [string(parent(f).S)])[1]
R = polynomial_ring(base_ring(f.matrix), nrows(f.matrix) )[1]
t = polynomial_ring(F,"t")[2]
t = polynomial_ring(F,"t")[2]
T = polynomial_ring(base_ring(S), n-1)[1]
@vtime :Subfields 2 ff = interpolate(polynomial_ring(F)[1], R, [con[findfirst(x->i in x, bs)] for i=1:length(R)]) # should be the embedding poly
R, x = polynomial_ring(QQ, "x")
R, x = polynomial_ring(QQ, "x")
R = polynomial_ring(ZZ, n)
Cx, x = polynomial_ring(C, append!(["x$i" for i in 1:n], ["x$i^-1" for i in 1:n]))
T, _ = polynomial_ring(K, m + n)
S, = polynomial_ring(codomain(coefficient_map(f)), _nvars(domain(f)))
S_flat, _ = polynomial_ring(kk, vcat(symbols(S), symbols(R)))
T_flat, _ = polynomial_ring(kk, vcat(symbols(S), symbols(R)))
T_flat, _ = polynomial_ring(kk, vcat(symbols(S), symbols(R)))
T_flat, _ = polynomial_ring(kk, vcat(symbols(S), symbols(R)))
polynomial_ring(K::NfNSGen{T, S}) where {T, S} = base_ring(defining_ideal(K))::parent_type(S)
gens(K::NfNSGen) = [K(x) for x = gens(polynomial_ring(K))]
gen(K::NfNSGen, i::Int) = K(gen(polynomial_ring(K), i))
number_of_generators(K::NfNSGen) = number_of_generators(polynomial_ring(K))
base_field(K::NfNSGen) = base_ring(polynomial_ring(K))
parent(a) !== polynomial_ring(K) &&
return K(polynomial_ring(K)(a))
return K(polynomial_ring(K)(a))
sr, _ = Singular.polynomial_ring(scr, symbols(r); ordering = singular(ord))
r, v = polynomial_ring(K, vcat(xs, dxs))
bspolyring, _ = Singular.polynomial_ring(a.sring.base_ring,
b = PBWAlgRing{T, S}(bsring, bsrel, a.coeff_ring, polynomial_ring(a.coeff_ring, revs)[1])
sr, _ = Singular.polynomial_ring(base_ring(R.sring), symbols(r); ordering = o)
sym_FM, s = polynomial_ring(R, Symbol.(var_names))
sym_F, t = polynomial_ring(R, [Symbol("t$i") for i in 1:rank(F)])
S, s = polynomial_ring(R, Symbol.(var_names))
S, s = polynomial_ring(R, Symbol.(var_names))
function cellular_associated_primes(I::MPolyIdeal{QQMPolyRingElem}, RQQAb::MPolyRing = polynomial_ring(abelian_closure(QQ)[1], symbols(base_ring(I)))[1])
RQQAb = polynomial_ring(QQAb, symbols(base_ring(I)))[1]
RQQAb = polynomial_ring(QQAb, symbols(base_ring(I)))[1]
RQQAb = polynomial_ring(QQAbcl, symbols(R))[1]
function cellular_primary_decomposition(I::MPolyIdeal{QQMPolyRingElem}, RQQAb::MPolyRing = polynomial_ring(abelian_closure(QQ)[1], symbols(base_ring(I)))[1])
RQQAb = polynomial_ring(QQAb, symbols(base_ring(I)))[1]
RQQAb = polynomial_ring(QQAb, symbols(base_ring(I)))[1]
RQQAb = polynomial_ring(QQAb, symbols(base_ring(I)))[1]
Qxy, gQxy = polynomial_ring(FlintQQ, length(U)+length(R)+length(D)+length(L))
SR_destination, = Singular.polynomial_ring(base_ring(G.Sx),["$i" for i in gens(G.Sx)]; ordering = Singular.ordering_as_symbol(singular(ordering)))
ModP, _ = polynomial_ring(base_field, ngens(base_ring(I)))
parent, t = (parent === nothing) ? polynomial_ring(ZZ, "t") : (parent, first(gens(parent)));
# S, _ = polynomial_ring(ZZ, VAR)
S, _ = polynomial_ring(coefficient_ring(R), length(v), "t")
T, _ = polynomial_ring(base_ring(R), ngens(R) + length(v))
S, _ = polynomial_ring(base_ring(R), [ "t$i" for i in 1:length(v) ])
S, _ = polynomial_ring(K, length(V), "t")
S2, _ = polynomial_ring(K, length(res), "t")
newOR, _ = polynomial_ring(br, [string(x) for x in gens(newSR)])
R, v... = polynomial_ring(C, args...; kwargs...)
Rx, _ = polynomial_ring(R, symbols(Qx))
return Singular.polynomial_ring(Oscar.singular_coeff_ring(base_ring(base_ring(R))),
singC, _ = Singular.polynomial_ring(Oscar.singular_coeff_ring(base_ring(C)),
ext_R, _ = polynomial_ring(coefficient_ring(R), vcat(symbols(R), Symbol.(v)))
ext_R, _ = polynomial_ring(coefficient_ring(R), vcat(Symbol.(v), symbols(R)))
Rnew, new_vars = polynomial_ring(coefficient_ring(R), kept_var_symb)
RR, _ = polynomial_ring(L, symbols(R))
R, _ = polynomial_ring(QQ, n + 1)
base = polynomial_ring(base_field(parent_ring), n)[1]
poly_ring = polynomial_ring(base_field(K), n)
Rtx,tx = polynomial_ring(R,vcat([:tsim],symbols(base_ring(I))))
Kx,x = polynomial_ring(K,xSymbols)
Kx,(x,y,z) = polynomial_ring(QQ,3)
Ktx,(x,y,z) = polynomial_ring(Kt,3)
_,x = polynomial_ring(TT,length(first(expvs)))
kx, _ = polynomial_ring(residue_field(nu),symbols(parent(f)))
Kx,(x,y,z) = polynomial_ring(QQ,3)
Kx,(x1,x2,x3,x4,x5) = polynomial_ring(QQ,5)
Kx,(x,y,z) = polynomial_ring(QQ,3)
Ktx,(x,y,z) = polynomial_ring(Kt,3)
Kx,(x,y,z) = polynomial_ring(QQ,3)
Ktx,(x,y,z) = polynomial_ring(Kt,3)
function polynomial_ring(R::TropicalSemiring, s::Symbol; cached::Bool = true)
Tx,x = polynomial_ring(T,[repr(x) for x in gens(parent(f))])
# Tx,x = polynomial_ring(T,[repr(x) for x in gens(parent(f))])
return polynomial_ring(base_ring(valued_field(nu)),symbols(valued_field(nu)))[1]
Kxhx,_ = polynomial_ring(K,vcat([:xh],x))
# Kx,(x1,x2,x3,x4) = polynomial_ring(K,4);
@RafaelDavidMohr and I will take care of this.
Since @ederc and @RafaelDavidMohr are working on this, triage had nothing to discuss
I looked a bit more into this issue, but to tell you the truth, I may not understand completely what to do. At the moment we have this behaviour:
julia> R, (x,y) = polynomial_ring(QQ, ["x", "y"]; cached = false)
(Multivariate polynomial ring in 2 variables over QQ, QQMPolyRingElem[x, y])
julia> S, (x,y) = polynomial_ring(QQ, ["x", "y"]; cached = false)
(Multivariate polynomial ring in 2 variables over QQ, QQMPolyRingElem[x, y])
julia> R == S
false
So this means that many tests will break if we are not caching internally constructed rings since the objects we return are usually connected with those rings. Looking at the code checking equality of non-cached rings R == S
it boils down to
==(x, y) = x === y
in julia Base.jl
. Is this really what we want?
Yes, I think this is what we want. Can you elaborate on the
So this means that many tests will break if we are not caching internally constructed rings since the objects we return are usually connected with those rings.
Which tests are among the many tests?
On Thu, Jun 06, 2024 at 12:25:25AM -0700, ederc wrote:
I looked a bit more into this issue, but to tell you the truth, I may not understand completely what to do. At the moment we have this behaviour:
julia> R, (x,y) = polynomial_ring(QQ, ["x", "y"]; cached = false) (Multivariate polynomial ring in 2 variables over QQ, QQMPolyRingElem[x, y]) julia> S, (x,y) = polynomial_ring(QQ, ["x", "y"]; cached = false) (Multivariate polynomial ring in 2 variables over QQ, QQMPolyRingElem[x, y]) julia> R == S false
So this means that many tests will break if we are not caching internally constructed rings since the objects we return are usually connected with those rings. Looking at the code checking equality of non-cached rings
R == S
it boils down to==(x, y) = x === y
in julia
Base.jl
. Is this really what we want? Yes.
The problem is, conceptually: here you set yourself up to expect true: you deliberately create the ring twice, immediately after each other.
Now consider a different scenario: you compute a normalisation, which will return a "new" polynomial ring and you compute a, don't know, blow-up that also creates a polynomial ring. Would you be happy to have the 2 rings be compatibel if the programmers randomly choose to call the variables x and y?
To make things worse: suppose a ring is created to represent some fin. gen. algebra. As such, the special-printing code is used to reflect that. Now, by chance, you create a ring with the same variables. If the ring is the "same", it will either
-- Reply to this email directly or view it on GitHub: https://github.com/oscar-system/Oscar.jl/issues/2455#issuecomment-2151583977 You are receiving this because you were mentioned.
Message ID: @.***>
Well, let's say something like this from AffineRationalPoint.jl
:
A2 = affine_space(GF(2), [:x, :y]);
(x, y) = coordinates(A2);
X = algebraic_set(x*y);
pA = A2([1,0])
A2a = affine_space(GF(2), [:x, :y]);
@test A2a([1,0]) == pA
On Thu, Jun 06, 2024 at 12:41:25AM -0700, ederc wrote:
Well, let's say something like this from
AffineRationalPoint.jl
:A2 = affine_space(GF(2), [:x, :y]); (x, y) = coordinates(A2); X = algebraic_set(x*y); pA = A2([1,0]) A2a = affine_space(GF(2), [:x, :y]); @test A2a([1,0]) == pA
But the "same" affine space can (will be) a different patch of some projective object? And as such should be different? -- Reply to this email directly or view it on GitHub: https://github.com/oscar-system/Oscar.jl/issues/2455#issuecomment-2151611208 You are receiving this because you were mentioned.
Message ID: @.***>
@fieker @thofma I can understand the behaviour of non-cached rings, the problem is just that then this issue is nothing @RafaelDavidMohr and I can solve on our own globally. Then everybody has to take care of her/his own code. I don't think it is a good idea if @RafaelDavidMohr and I change tests for code where we do not have expertise.
Agreed.
Once the referenced PRs are all merged, this issue can be closed. As discussed, the open PRs need adjustments in tests. I asked the corresponding authors for support.
Thank you @ederc
This was brought to my attention by @fieker. Apparently, this happens in particular for schemes. Hence, I cc @HechtiDerLachs , so we can discuss this at some point.